Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 683
  • Last Modified:

count records in .csv file in a directory

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
d27m11y
Asked:
d27m11y
  • 3
1 Solution
 
ozoCommented:
What determines what "record" is?
If each line is a record, you can use wc
0
 
d27m11yAuthor Commented:
I just want to skip the first line and count rest all of them
0
 
d27m11yAuthor Commented:
I am just using wc -l *.csv ?, looks likethis works
0
 
nemws1Commented:
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
 
d27m11yAuthor Commented:
Very helpful !
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now