Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Improvement of LINUX disk usage command DU

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

We know that under Linux, if you want to know the size of each file or subdirectory in the current directory, you can use the du command to do this. Such as:

1$ du-sh *

This command displays the size of each file and subdirectory in the form of KJM _ G. We call this method human-readable, which is a way that people can read it, as follows:

8.4G Desktop

2.6G Documents

12K keys

12M Pictures

536K scripts

However, it is a pity that our du does not provide the relevant sorting function, so it is very difficult to use the sort command to sort under human-readable, that is, the-h parameter. Because that becomes a string sort, the decimal point, the number of digits of the number, and the unit K _ M _ M _ G all make the sorting confusing. So, how can we have the function of human-readble and sort it? We have to borrow some scripting languages to deal with it.

Here is the use of Perl to achieve this:

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report