Hi Everyone
If i do this
cat /usr/local/data/sales/taxware/indata/stepprod |wc -l
i'll get output like this
5
And now i want to add a word for this output 'stepprod' (no quotes, only word) like below
stepprod 5
Thank you
Hi Everyone
If i do this
cat /usr/local/data/sales/taxware/indata/stepprod |wc -l
i'll get output like this
5
And now i want to add a word for this output 'stepprod' (no quotes, only word) like below
stepprod 5
Thank you
cat /usr/local/data/sales/taxware/indata/stepprod |wc -l | xargs echo stepprod
This is an other way to do it:
echo stepprod `cat your_file |wc -l`
No need to use cat:
echo "stepprod $( wc -l < file )"
Or, may be a bit more flexible:
FN=/usr/local/data/sales/taxware/indata/stepprod
echo ${FN##*/} $( wc -l < $FN )
hi arun if follow your answer iam getting output like....
stepprod a b c d e f g h i j k l
but i need the total count of my file.. it means i want output like below
stepprod 12
Thank you for your reply
If you skip the unneeded calls to cat and don't care about whether the filename comes before or after the line count, it would be much more efficient to just use:
wc -l /usr/local/data/sales/taxware/indata/stepprod
which with your sample data would produce something like:
5 /usr/local/data/sales/taxware/indata/stepprod
or:
cd /usr/local/data/sales/taxware/indata/
wc -l stepprod
which would produce something like:
5 stepprod
And, if you have more than one file to count:
wc -l stepprod file2 file3
might give you something like:
5 stepprod
12 file2
1000 file3
1017 total
To get exact ouptu as you want with the the file name for which you are trying to get,
awk '{ line++; } END { print FILENAME" "line}' filename