Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello All, I've a unix script th

Status
Not open for further replies.

toronto2003

IS-IT--Management
May 5, 2003
14
CA
Hello All,

I've a unix script that runs as a cron job to look for three *.csv files on a particular machine, do a record count in the *.csv files and report it via email.

Currently even if there are no records in the *.csv files, it reports are record count=1. How can i take off this header information. If there are no records in the csv files, it should report as '0'.

Any help on this would be highly appreciated.

Thanks!
 
To get the record count, subtract 1 from the line count, i.e....

#----Bourne shell
countA=`wc -l <fileA.csv`
countA=`expr $countA - 1`

#----Korn shell
(( countA = $(wc -l < fileA.csv) - 1 ))

echo record count for fileA is $countA
 
Hello Ygor,

Thanks for your help and reply back.

In my script the echo statement reporting the count is

echo &quot;File $my_dir/$i present with $(cat $i|wc -l) records.&quot;

Where and how should i embedd the

(( countA = $(wc -l < fileA.csv) - 1 ))

Please help

Thanks!
 
echo &quot;File $my_dir/$i present with $(( $(wc -l < $i) - 1 )) records.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top