Hi all
Thanks in advance...........
Please help me for this issue............
I have a file it has 11 records . I used the command like ....
>$ wc -l file
11 file
I'm getting output like 11 file (no.of records along with filename)
here my requirement is, I want to display only no.of records without filename
like only 11.
can anyone please tell me which command I have to use?
because if I get this no.of records I have to comapre with some outfile
so shall I assign this no.of records to any variable ?
Thanks
Srivani Kolachina
try this
wc -l < file
otherwise, use awk, cut,...etc...
---------- Post updated at 12:44 PM ---------- Previous update was at 12:31 PM ----------
grep -c . file
---------- Post updated at 12:44 PM ---------- Previous update was at 12:44 PM ----------
awk '{i++;} END{print i}' file
---------- Post updated at 12:46 PM ---------- Previous update was at 12:44 PM ----------
perl -lane '$i++;END{print $i}' file
Thanks a lot ....
>$ wc -l < file
11
But I want to assgin this output to any variable?
I'm declaring like below.
j=wc -l < file
k=wc -l <outfile
if [ $j -eq $k ]
then
echo " both are same "
else
echo " not same"
fi
my program is like this ... but it is giving error like
ex: line 13: -l: command not found
+ k=wc
+ -l
ex: line 14: -l: command not found
but giving the output properly...
can u please tell me y it is giving like this?
Thanks
Srivani
j=`wc -l < file`
k=`wc -l <outfile`
use back ticks
or use it like below
j=$(wc -l < file)