Linux ls statistics on the number of files in a folder ls-l | grep "^-" | wc-l statistics on the number of files in a folder ls-l | grep "^ d "| wc-l: count the number of files in the folder, including ls-lR | grep "^-" | wc-l in subfolders, for example, all js files in the/home/han directory (including subdirectories: ls-lR/home/han | grep js | wc-l or ls-l "/home/han" | grep "js" | wc-l counts the number of directories in the folder, including ls-lR | grep "^ d" | wc-l in the subfolder description: The ls-lR long list outputs the file information in this directory (R indicates the sub-directory. Pay attention to the files here, different from common files, such as directories, links, and device files.) grep "^-" filters out a part of the long list output information and only keeps the general file, if you keep only the directory ^ d wc-l, Because only general files are filtered out, the statistical result is the number of rows of the general file information. Because one row of Information corresponds to one file, it is also the number of files. ================================================== Only one ls-d folder can be displayed. find-type d: You can see the sub-Folder ls-lF | grep/or ls-l | grep '^ d'. Only the folders in the current directory are displayed, excluding the following folders.