Number of records in a file of a particular directory

Hi All,

I want to find the number of records in a file of a particular directory

I have a file as abcd.txt in the path
var/hr/payments/

I want to find number of records in abcd.txt file in a single command.

I tried the following

cd /var/hr/payments/wc -l abcd.txt

I got the error "ksh: cd: bad argument count"

Please help me to get this.

Thanks in advance.

cd /var/hr/payments/; wc -l abcd.txt 

cat /var/hr/payments/abcd.txt | wc -l

useless use of cat
Useless Use of Cat Award

1 Like

Thanks for your help

Could you please help me to print the count as
Number of records in the file abcd is 1122.
Thanks in advance

awk 'END{print "Number of records in the file " FILENAME " is " NR}' /var/hr/payments/abcd.txt