Linux ls statistics file count

Source: Internet
Author: User

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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.