# View the number of files in the current directory (not including files in subdirectories)
ls -l| grep " ^- " WC -L
# View the number of files in the current directory (including files in subdirectories) Note: R, which represents subdirectories
ls -lr| grep " ^- " WC -L
# View the number of folder directories in the current directory (without directories in subdirectories), with the above manager, if you need to view subdirectories, plus R
ls -l| grep " ^d " WC -L
# Query the number of all files under the directory with the specified prefix name under the current path
# For example: Count all the files in the directory starting with "20161124"
ls 20161124*/| grep " ^- " WC -L
Make a note of each command parameter:
Ls-l
This command indicates that the information in the specified directory is output as a long list (not specified as the current directory), and R represents a "file" in the subdirectory, which refers to the generic name of the directory, link, device file, etc.
grep "^d" represents the directory,"^-" represents the file
Wc-l
Represents the number of rows of statistical output information, because the previous filter has left only ordinary files, a directory or a file corresponding to a row, so the number of rows of statistics is the number of directories or files
"Linux" Linux statistics folder, number of files command