Solved

count records in .csv file in a directory

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 95
Batch Login Script - Update default homepage 8 50
Martian Packets Unix 5 52
Adding a continue option in a script 9 40
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…
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

810 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