In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you the "Linux how to enumerate files larger than the specified size of the directory", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to enumerate the directory of files larger than the specified size in Linux" this article.
In Linux systems, it is often necessary to clean up some large files to expand the free space of the disk. But before you clean up these files, you need to find them, or list all the large files in the Linux directory. This paper takes the awk command as an example.
Business background
The / home/pms directory is a working directory. Now the directory takes up too much hard disk space and needs to be cleaned up. Now you need to enumerate all the subfile directories larger than 200MB in this directory, as well as the space occupied by the subfile directory.
Script implementation
Du-h-- max-depth=10 / home/pms/* | awk'{if ($1 ~ / M /) {split ($1, arr, "M")}; if (($1 ~ / G /) | | ($1 ~ / M / & & arr [1] "200)) {printf"%-10s% s\ n ", $1, $2}'| sort-n-r
Among them
Du-h-max-depth=10 / home/pms/*
The results are as follows
$du-h-max-depth=10 / home/pms/*
0 / home/pms/addressCountMap
12K / home/pms/bigDataEngine/conf
1.7M / home/pms/bigDataEngine/analysis/warning
33M / home/pms/bigDataEngine/analysis/log
...
The following awk statement is used to determine the first parameter, to match the string, and to intercept the character M if it is M
If ($1 ~ / M /) {split ($1, arr, "M")}
The following awk statement is used to determine the first parameter and match the string:
1. M, determine whether the capacity is greater than 200MB, and then directly output parameter 1 and parameter 2.
2. Direct output parameters 1 and 2
If (($1 ~ / G /) | ($1 ~ / M / & & arr [1] "200)) {printf"%-10s% s\ n ", $1, $2}
Output result
$du-h-- max-depth=10 / home/pms/* | awk'{if ($1 ~ / M /) {split ($1, arr, "M")}; if (($1 ~ / G /) | | ($1 ~ / M / & & arr [1] "200)) {printf"%-10s% s\ n ", $1, $2}'| sort-n-r
The above is all the contents of the article "how to list directories with files larger than the specified size in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.