How to query the number of files per file by command

Source: Internet
Author: User

Server managers often encounter more than 250,000 of the number of files in the customer request to query which directories are larger than the number of files, such a customer pulic_html directory of subdirectories are generally good dozens of, the query is very difficult, if each directory runs a file Count command, it takes at least 30 minutes. The following method can quickly query the directory with a higher number of files.

Login to the corresponding SSH, execute the command:

#cd/home/username/public_html

#du-S | Sort-n #查询目录磁盘占用

#find. -printf "%i\n" | Sort-u | Wc–l #统计当前目录的文件数

or run directly:

#du-S/home/username/public_html/* | Sort-nr #查询目录磁盘占用

#find. -printf "%i\n" | Sort-u | Wc–l #统计当前目录的文件数

Depending on the directory disk consumption to determine the size of the directory files, only need to count the disk occupies a large directory can be, without traversing the query, you can save a lot of time. In addition count the number of files in the current directory can be ordered:

#find. | Grep-v \/$ | Wc-l substitution (personally feel relatively good to remember).

URL Address: http://www.bianceng.cn/Servers/zs/201602/49620.htm

This article is from the "Dudu Growth Diary" blog, please be sure to keep this source http://3402313.blog.51cto.com/3392313/687190

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.