Linux,mac down LS View directory (folder) content size

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.