Find out large file commands in CentOS

Source: Internet
Author: User
Q. How can I find all the large files in the directory? A.1) syntax forRedHat/CentOS/FedoraLinuxfind {/path/to/directory/}-typef-size + {size-in-kb} k-execls-lh {}\; | awk & lsquo; {print $9 & ldquo;

Q. How can I find all the large files in the directory?

A.

1) syntax for RedHat/CentOS/Fedora Linux

Find {/path/to/directory/}-type f-size + {size-in-kb} k-exec ls-lh {}\; | awk '{print $9 ":" $5 }'

Instance:
Search for files larger than 50 MB in the current directory
$ Find.-type f-size + 50000 k-exec ls-lh {}\; | awk '{print $9 ":" $5 }'

Search for files whose directory/var/log is greater than MB
# Find/var/log-type f-size + 100000 k-exec ls-lh {}\; | awk '{print $9 ":" $5 }'

2) syntax for Debian/Ubuntu Linux
Find {/path/to/directory}-type f-size + {file-size-in-kb} k-exec ls-lh {}\; | awk '{print $8 ":" $5 }'

Instance:
Search for files larger than 10 MB in the current directory
$ Find.-type f-size + 10000 k-exec ls-lh {}\; | awk '{print $8 ":" $5 }'

Sample output:
./. Kde/share/apps/akregator/Archive/http ___ blogs.msdn.com _ MainFeed. aspx? Type = AllBlogs. mk4: 91 M
./Out/out.tar.gz: 828 M
./. Cache/tracker/file-meta.db: 101 M
./Ubuntu-8.04-desktop-i386.iso: 700 M
./Vivek/out/mp3/Eric: 230 M

List files with a file size smaller than B in the home directory:
$ Find $ HOME-size-500b
OR
$ Find ~ -Size-500b
List files with a size of 20 512-byte blocks in the root directory:
# Find/-size 20

Perl tips: display large files
Displays the usage of each directory in the current directory based on the file size from small to large (note: the length of asterisks and stars)

Du-k | sort-n | perl-ne 'if (/^ (\ d +) \ s + (. * $)/) {$ l = log ($1 +. 1); $ m = int ($ l/log (1024); printf ("% 6.1f \ t % s \ t % 25 s % s \ n ", ($1/(2 ** (10 * $ m), ("K", "M", "G", "T", "P ") [$ m]), "*" x (1.5 * $ l), $2 );}'

Ls command: find the largest file in the directory
You can also use the ls command:
$ Ls-lS
$ Ls-lS | less
$ Ls-lS | head + 10
Ls command: Find the smallest file in the directory
As follows:
$ Ls-lSr
$ Ls-lSr | less
$ Ls-lSr | tail-10

Other supply:

Find.-xdev-printf '% s % p \ n' | sort-nr | head-20
Du-xak. | sort-n | tail-50

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.