Quantcast
Channel: Count the occurrences of a string in a file - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 4

Answer by George Vasiliou for Count the occurrences of a string in a file

$
0
0

Just for the record, the all time classic awk:

awk '/\.java$/{++c}END{print "Total java files:" c}' file

If you want to print also those filenames you can change {++c} to {print;++c}.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>