Simple to find file and directory sizes in Linux is simple
#已易读的格式显示指定目录或文件的大小,-s option specifies that each subdirectory or file size is not displayed in detail for the directory
Du-sh [Dirname|filename]
Such as:
Size of current directory:
Code to copy code as follows
Du-sh.
The size of the next file or directory in the current directory:
Code to copy code as follows
Du-sh *
Show the top 10 most space-occupying files or directories:
Code to copy code as follows
Du-s * | Sort-nr | Head
*-H readable format displays the size of the specified directory or file
*-s option specifies that each subdirectory or file size is not displayed in detail for the directory
How do I find all the large files in the directory?
The Find command under Linux is used to look up files and know that it is omnipotent through man find. So you can find files by file size. To search for size from man find, you can see the following information:
-size N[CWBKMG]
File uses n units of space. The following suffixes can be used:
b for 512-byte blocks (the "the default if no suffix is used)
C for bytes
W for two-byte words
K for kilobytes (Units of 1024x768 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, so 2 means 1k,1m is 2048, if you do not want to convert, you can use other units, such as C, K, m, etc.
A.
1) syntax for Redhat/centos/fedora Linux
Code to copy code as follows
Find {/path/to/directory/}-type f-size +{size-in-kb}k-exec ls-lh {}; | awk ' {print $9 ': ' $ $ '
Instance:
Find files larger than 50MB in the current directory
Code to copy code as follows
$ find. -type f-size +50000k-exec ls-lh {}; | awk ' {print $9 ': ' $ $ '
Find a directory/var/log files larger than 100MB
Code to copy code as follows
# Find/var/log-type F-size +100000k-exec ls-lh {}; | awk ' {print $9 ': ' $ $ '
2) syntax for Debian/ubuntu Linux
Find {/path/to/directory}-type f-size +{file-size-in-kb}k-exec ls-lh {}; | awk ' {print $8 ': ' $ $ '
Instance:
Find files larger than 10MB in the current directory
Code to copy code as follows
$ find. -type f-size +10000k-exec ls-lh {}; | awk ' {print $8 ': ' $ $ '
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 files with file sizes less than 500b in home directory:
Code to copy code as follows
$ find $HOME-size-500b
OR
$ find ~-size-500b
Lists the files in the root directory that are size 512-byte blocks:
Code to copy code as follows
# Find/-size 20
Find out large File command summary in CentOS