Linuxls statistics on the number of files in a folder ls-l | grep & quot; ^-& quot; | wc-l... 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" ^-"Here, the output information of the long list is filtered out, and only the general files are retained. if only the directory is retained, the number of rows of the output information is ^ 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.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.