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 complete this action. Such as:
$ du -sh * This command can display the size of each file and subdirectory in K, M, G mode. We call this method, human-readable, which is the way people can read, as follows:
8.4G Desktop2.6G Documents12K keys12M Pictures536K scripts However, it is a pity that our du There is no related sorting function, so if under human-readable, that is, the -h parameter, it is difficult to sort using the sort command. Because that becomes a string sort, the decimal point, the number of digits, and the units K, M, G will make the sorting confusing. So, how can we have the human-readble function and sorting? We have to borrow some scripting language to handle it.
The following is the use of Perl to achieve this:
du -sk * |
Sort -n |
# Sort perl -ne ' in K-bytes # #Use Perl to handle KM and G units ($s,$f)=split(m{\\t}); #separate size/file names for (qw(KMG) )) { # Cycles in size units if($s<1024) { #if size<1024 then printf("%.1f",$s); #display file size print "$_\\t$ f"; #display file name last #换行}; $s=$s/1024 #除1024 and then enter the next size unit}
When I maintain the blog file today, I found that I cant delete some folders and files in the websi
The Linux operating system has been around for 20 years without knowing it. Just 20 years ago, just
Starting today, I officially entered the development of tiny4412. Today I mainly watched the startu
In order to ensure the normal operation of the Linux system and accurately solve various system prob
How to find IP address conflicts in Linux
How to remove the old kernel of Ubuntu Linux operating system
How to turn off UseDNS to speed up SSH login
How to check the number of CPUs under Linux system
19 thoughts clearly understand the load balancing under Linux
Linux startup process GRUB detailed
Remember that the Auto Increment fault
Briefly explain the four intrusion levels for Linux servers
A detailed introduction to Debian
How to set the optimal resolution for win10 system? Win10 set the best resolution method
How to install Win8.1? Install the win8.1 tutorial from the hard disk /CD /u disk diagram
Old people often talk about network skills in Win XP
Win10 Preview: "Home" is easy to use?
Win7 boot speed is slow with QQ computer housekeeper one-speed speed up
Win7 can not open the local disk how to do
How to modify the default installation path of Windows 8 application