Find the summary of large file commands in centos

Source: Internet
Author: User
In linux, it is easy to simply find the file and directory size # the size of the specified directory or file is displayed in an easy-to-read format, the-s option specifies that the du-sh [dirname | filename] of each subdirectory or file is not displayed in detail for the directory. for example, the size of the current directory is as follows: Copy the code du-sh as follows. when

In linux, it is easy to find files and directories.

# The size of the specified directory or file is displayed in a readable format. the-s option specifies that the size of each subdirectory or file is not displayed in detail for the directory.

Du-sh [dirname | filename]

 

For example:

 

Current Directory size:

The code is as follows:

Du-sh.

 

Size of files or directories in the current directory:

The code is as follows:

Du-sh *

 

Display the first 10 most occupied files or directories:

The code is as follows:

Du-s * | sort-nr | head

*-H the readable format shows the size of the specified directory or file

* The-s option specifies that the size of each subdirectory or file is not displayed in detail for the directory.

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

The find command in linux is used to find files. man find can be used to find files that are omnipotent. Therefore, simply find the file according to the file size. Search for the size from man find. the following information is displayed:

-Size n [cwbkMG]

File uses n units of space. The following suffixes can be used:

B for 512-byte blocks (this is the default if no suffix is used)

C for bytes

W for two-byte words

K for Kilobytes (units of 1024 bytes)

M for Megabytes (units of 1048576 bytes)

G for Gigabytes (units of 1073741824 bytes)

Note: The default unit is B, and it represents 512 bytes. Therefore, 2 indicates 1 K, and 1 m indicates 2048. if you do not want to convert it yourself, you can use other units, such as c, K, and M

A.

1) syntax for RedHat/CentOS/Fedora Linux

The code is as follows:

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

The code is as follows:

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

Search for files whose directory/var/log is greater than MB

The code is as follows:

# 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

The code is as follows:

$ 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:

The code is as follows:

$ Find $ HOME-size-500b

OR

$ Find ~ -Size-500b

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

The code is as follows:

# Find/-size 20

Related Article

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.