Reputation: 61
I'm not quite sure how to print the file name being processed from within a for loop in linux. I realize that similar questions have been asked, but I haven't successfully adapted any of the suggested responses yet.
I'm trying to entries in a file and output the file name. Each individual entry is made up of 4 lines, which is the reason that I’m dividing by 4. I can easily count the entries via:
for i in *.gz; do expr $(cat $i | wc -l) / 4; done
But how can I output the filename?
Thanks for your help! Ryan
Upvotes: 0
Views: 29
Reputation: 15204
Does this help?
for i in *.gz
do
echo "$i"
expr $(cat "$i" | wc -l) / 4
done
Upvotes: 1