Solved

count records in .csv file in a directory

Posted on 2013-06-12
5
671 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
ID: 39241087
What determines what "record" is?
If each line is a record, you can use wc
0
 

Author Comment

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

Author Comment

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

Accepted Solution

by:
nemws1 earned 500 total points
ID: 39241294
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
ID: 39241491
Very helpful !
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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.

740 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