1

Count number of lines with a certain value in a column for all files in directory recursively

view story
linux-howto

http://unix.stackexchange.com – I have 40 files in a directory and I want to count the number of times there is a line with a "2" in the first column in each file individually. I am trying something like this, but it prints out the total sum from each file and I want the individual sums: find . -type f -print0 | xargs -0 awk '($1=="2"){++count} END {print count}' Just to make it clear this is an example: FILE_1 2 345 123 4 2 4567 2344 6 3 2345 657 87 6 234 345 6 FILE_2 1 12 436 7 2 54 86 8 2 23 48 0 2 098 0 8 8 98 9 0 PRINT: FILE_1 2 FILE_2 3 What I'm ac (HowTos)