How to Find Large Files or Directories in Linux Summary

http://my.oschina.net/u/1034537/blog/611045How

to find large files
1. To search for files over 800M in size in the current directory
find . -type f -size +800M


2. If you don't know anything about the file information (for example, file size, file attributes), can you display some file attributes or information in more detail, of course, as shown below
find . -type f -size +800M  -print0 | xargs -0 ls -l


3. When we only need to find files with a size of more than 800M and display the specific size of the found files, we can use the following command
find . -type f -size +800M  -print0 | xargs -0 du -h


4. If you also need to sort the search results by file size, you can use the following command
find . -type f -size +800M  -print0 | xargs -0 du -h | sort -nr




How to Find Large Directories in Linux
1. For example, sometimes the disk space is alarmed, and you usually neglect to manage and monitor the growth of files, then I need to quickly understand which directories become larger, then we can use du command to help us solve this problem.
du -h --max-depth = 1


2. If you want to know which large folders are under the flash_recovery_area directory, you can set the parameter max-depth=2. If you want to sort the search results, you can use the sort command. As follows
du -h --max-depth=2 | sort -n

or
du -hm --max-depth=2 | sort -n



3. Sometimes there are too many results from the search (for example, I start the search from the root directory), and the screen keeps swiping. What if I only want to find the largest 12 folders? At this point, it is necessary to use the head command to display
du -hm --max-depth=2 | sort -nr | head -12

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326779475&siteId=291194637