【Shell】Count the number of files in a directory

Counting the number of all types of files

ls -lR /path/ | grep "^-" | wc -l

R represents searching for files in all subdirectories

^- represents searching for regular files

^d represents searching for directories

wc -l represents counting the number of output lines

Counting the number of specific type of files

ls -lR /path/ | grep "type" | wc -l

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.