"Linux" Linux statistics folder, number of files command

Source: Internet
Author: User

# 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

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.