Linux find large files or directories

Source: Internet
Author: User

1.Linux find large files or directories 1.1 files that exceed a specified size in the specified directory, only show path + file name
find ./-type f-size +20M. /elasticsearch-6.2. 4 . rpm. /shakespeare_6. 0. JSON

1.2 Search for files that exceed a specified size in the specified directory (file size only, filename)

Method 1

Find Xargs ls awk ' {print $5,$9} ' 28M. /elasticsearch-6.2. 4 . rpm25m. /shakespeare_6. 0. JSON

Method 2

Find Xargs du -h28m      . /elasticsearch-6.2. 4 . rpm25m      . /shakespeare_6. 0. JSON

1.3 Search for files larger than the specified size in the specified directory (size sort)
Find Xargs ls awk ' {print $5,$9} ' sort -nr28m. /elasticsearch-6.2. 4 . rpm25m. /shakespeare_6. 0. JSON

1.4 Find a large directory under Linux

Generally df-h can only view the usage of disk partitions, which is obviously more appropriate for the directory size du command

Find a large directory under a specified directory

du -h/usr/--max-depth=1/usr//usr/sbin529m    /usr/lib159m     /usr/lib641. 1G    /usr/share0   /usr/etc 0   /usr//usr//usr/libexec0   /usr/local0   /usr/src1. 9G    /usr/

Tips:

--max-depth=2 the deepest of the specified file is equivalent to-D2

-M like--block-size=1m

Show directory size from large to lower, and exclude empty directories

du -hm/usr/-d1| Sort grep " ^[^0] " 1927    /usr/1101    /usr/share529 /usr/Lib159 /usr/lib64    /usr/bin  /usr/sbin  /usr/ libexec 1   /usr/include

Linux finds large files or directories

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.