Accustomed to terminal does not know the LS command (the same as the Dos dir), often just need to see the contents of the directory size , but ls-h display is only the size of the directory itself, and many of the content
The two criticisms of LS in this regard have arisen:
Small guanxi 1. The information shown is very full, we only extract size and name two columns, respectively, 5th and 9 columns
But found the wrong, like the edge of the word at least 200G, but why the display is 306B, indicating that LS just shows the size of the directory itself, does not display the content size
Big Guanxi 2. Do not display the actual size of the directory, to display the contents of the directory (folder) size, you need to use DU (disk utility abbreviation) to display
In this way, you can save this command as alias for later use,alias ldu= ' ls-1 | xargs du-h-d 0 2>/dev/null ' to. Bash_profile (Mac),. BASHRC (under Debian), source; The problem is that it only shows the current directory situation, if I want to see the edge under the directory is larger, the way is to first CD to that directory, in LDu, But it's annoying to lose such a long command every time, so I thought, turn it into a function
Put this function in the bash configuration file (. bashrc or. bash_profile), source, so that the effect is the same as LDU, and can also display a non-current directory , but I want to add the * wildcard character , For example, I want to show the size of the directory with P Open, and also can accept multiple directories as parameters
At the same time, make the acceptance * match
Also accept file size display correctly
Haha, the three concerns are lifted, the function is finally determined to be
Download as: lus.sh
Hehe Hee-hee, hee Hee-hee, hehe hee hee, very happy
Linux,mac down LS View directory (folder) content size