Monday, April 2, 2012

Linux commands - To find number of files on a folder

$ ls -al target_folder | grep '^-' | wc -l
$ 90

This is one of the command return number of files on a folder, Suppose target folder contains 90 files. This command output will be  "90"

If you want to find out number of files of specific extension for example .jar

$ ls -al target_folder | grep '^-' | grep 'jar$' | wc -l
$ 40

If target folder contains 40 jar files then result of above command would be 40

No comments:

Post a Comment