How To Count Files in Directory on Linux

$ ls | wc -l
$ ls /etc | wc -l

268

Count Files using tree

An easy way of counting files and directories in a directory is to use the “tree” command and to specify the name of the directory to be inspected.

$ tree <directory>

Leave a comment

Your email address will not be published. Required fields are marked *