Solved

count records in .csv file in a directory

Posted on 2013-06-12
5
667 Views
Last Modified: 2013-06-12
I have  a file named "i.Permal_Caxton_HAWK_20130326.csv"

and I wanted to count the number of records in that file in unix. Can I use grep.. please help, very immediate answer needed.
0
Comment
Question by:d27m11y
  • 3
5 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
What determines what "record" is?
If each line is a record, you can use wc
0
 

Author Comment

by:d27m11y
Comment Utility
I just want to skip the first line and count rest all of them
0
 

Author Comment

by:d27m11y
Comment Utility
I am just using wc -l *.csv ?, looks likethis works
0
 
LVL 23

Accepted Solution

by:
nemws1 earned 500 total points
Comment Utility
To skip the first line of a file, use tail:
tail -n +2 filename

Open in new window

You can then pipe that to wc:
tail -n +2 filename | wc -l

Open in new window

To count up all the lines (skipping the first line) of all your files, you could do this:
for i in *.csv
do
    tail -n +2 $i | wc -l
done | awk '{ t+=$1} END {print t}'

Open in new window

0
 

Author Closing Comment

by:d27m11y
Comment Utility
Very helpful !
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now