In continuation to my earlier post regarding concatenation similar files into one. I am writing this post to demonstrate counting lines of similar kind of files in a given directory and sub-directory.
Below command will find all the logs with given name pattern inside the directory including sub directories and then WC will count it’s lines and display on screen in total.
wc -l `find . -name usage*.log`
Sample output of command
Below command will not count the blank lines.
grep -cv ‘^\s*$’ `find . -name “usag*.log”`
Sample Output, see below blank lines are not counted.