Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to find all the large files in the directory under CentOS

Shulou Source: shulou.com Published: 2022-06-01 11:23:25 10月25日 Update

This article mainly explains "how to find all the large files in the directory under CentOS". The content in the article is simple and clear, and it is easy to learn and understand. Please follow Xiaobian's train of thought to study and learn "how to find all the large files in the directory under CentOS".

q. How do I find all the large files in the directory?

a.

1) syntactic for RedHat / CentOS / Fedora Linux

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

Example:

Find files greater than 50MB in the current directory

$find. -type f-size + 5000k-exec ls-lh {}\; | awk'{print $9 ":" $5} "

Find files whose directory / var/log is greater than 100MB

# find / var/log-type f-size + 100000k-exec ls-lh {}\; | awk'{print $9 ":" $5}'

2) syntactic for Debian / Ubuntu Linux

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

Example:

Find files greater than 10MB in the current directory

$find. -type f-size + 10000k-exec ls-lh {}\; | awk'{print $8 ":" $5}'

Sample output:

. / .kde / share/apps/akregator/Archive/http___blogs.msdn.com_MainFeed.aspx?Type=AllBlogs.mk4: 91M

. / out/out.tar.gz: 828M

. /. Cache/tracker/file-meta.db: 101M

. / ubuntu-8.04-desktop-i386.iso: 700M

. / vivek/out/mp3/Eric: 230M

List the files with a file size less than 500b in the home directory:

$find $HOME-size-500b

OR

$find ~-size-500b

List the files with a size of 20 512-byte blocks in the root directory:

# find /-size 20

Perl tip: display large files

Displays the occupancy of each directory under the current directory according to the file size from small to large (note: asterisk and asterisk length)

Du-k | sort-n | perl-ne'if (/ ^ (\ d +)\ s + (. * $) /) {$l=log ($1mm.1); $m=int ($l/log (1024)); printf ("% 6.1f\ t% s\ t% 25s% s\ n", ($1 / (2cm * (10cm), (("K", "M", "G", "T", "P") [$m]), "*" x (1.5cm), $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 lessons for you:

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

Du-xak. | sort-n | tail-50

Thank you for your reading, the above is the content of "how to find all large files in the directory under CentOS". After the study of this article, I believe you have a deeper understanding of how to find all large files in the directory under CentOS. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Files directories commands size learning content syntax examples situations asterisks maximum minimum small to big small that is ideas tips articles more root directory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS OPPO Reno Shulou Tech Info Apple Redmi