Solved

count records in .csv file in a directory

Posted on 2013-06-12
5
670 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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