|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Print record count of a file using shell script
HI,
I need to print the record count of a file using shell script. If the record count of a file excluding header and trailer record if greater than zero then print 'Record count of a file is xxxx records'. If the record count is zero print 'zero records' Thanks Mahendra |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
awk 'END{if (NR-2 == 0){print "Zero records"} else {print "Record count: " NR-2}}' file |
| Sponsored Links | ||
|
![]() |
| Tags |
| record count |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script for searching a record,copy to a file and then delete it | kumara2010 | Shell Programming and Scripting | 5 | 06-16-2010 10:33 AM |
| How to assign record count output of isql to a shell variable ? | vikram3.r | Shell Programming and Scripting | 4 | 05-26-2010 10:37 AM |
| shell script to get the arrival count of file | RSC1985 | Shell Programming and Scripting | 2 | 08-20-2009 04:49 AM |
| Record count of a csv file | ajaykk | Shell Programming and Scripting | 5 | 07-17-2008 05:16 PM |
| How to count the record count in an EBCDIC file. | oracle8 | UNIX for Dummies Questions & Answers | 1 | 07-26-2006 07:22 PM |
|
|