In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to find the largest file in Linux. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
The first kind: ls
The easiest way is to use the ls command, because the ls command itself outputs with file size information.
For example, I want to list the five largest files in the / bin directory, you can:
Ls-lSh / bin | head-5
The second kind: find
Find itself is a search command, and you can recursively find a subdirectory of a directory, so it's natural to use it.
For example, find the largest file in the / directory:
Sudo find /-type f-printf "% s\ t% p\ n" | sort-n | tail-1
If you want to find the top 10 large files, you can do this:
$find $HOME-type f-printf'% s% p\ n'| sort-nr | head-10
You can also use the-size option to find it, and the following command displays all files greater than 100MiB (note that it is not the difference between 100MB MIB and MB, emmm):
Find /-size + 100m-ls
You can also find a file between an interval size (such as 100MiB and 200MiB):
Find /-size + 100m-size-200m-ls
Finally, the following command is also commonly used to find the five largest files in a directory:
Find $DIRECTORY-type f-exec ls-s {}\; | sort-n | tail-n 5
In addition, find can also find the most recent files: files less than or equal to n days (- ctime-n) or files belonging to a specific user (- user mrlinus).
The third kind: du
The du command can be used to view disk space usage, and naturally it can also be used to view files and folders that take up more space on disk.
For example, look for the top 20 largest files under / home:
Sudo du-a / home | sort-n-r | head-n 20
Find the top 10 directories in the current folder:
Sudo du-a | sort-n-r | head-n 10
If you want to display readable KB, MB, GB information, you can add the-h parameter:
Du-hs * | sort-rh | head-n 10
Find the largest directory / file (including subfolders):
Du-Sh | sort-rh | head-n 10
If you only look at all files that are within the size of GB, you can use both the du command and the grep command:
Du-h-a / dir | grep "[0-9] G\ b" so much about how to find the largest file in Linux. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.