1. Count the number of files in the current folder
Ls-l |grep "^-" |wc-l
2 . Count the number of directories under the current folder
Ls-l |grep "^d" |wc-l
3. count the number of files in the current folder, including subfolders
Ls-lr|grep "^-" |wc-l
4. The number of directories under the statistics folder, including the sub-folders
Ls-lr|grep "^d" |wc-l
grep "^-"
In this case, the long list output information is filtered, only the general files are preserved, if only the directory is ^d
Wc-l
Statistics output information of the number of rows, because it has been filtered to only the general file, so the statistical results are general file information line number, and because one line of information corresponding to a file, so that is the number of files.
Reference: http://www.jb51.net/article/56474.htm
The shell counts the number of files and directories in the current folder