LS display unit when file size is displayed

Source: Internet
Author: User
Tags readable
When displaying file sizes in Linux, it is common practice to use "ls-l", which is the size of the file's byte size.
However, if the file is relatively large, the display is not particularly readable, this time, you can use "LS-LH", you can use a relatively close to the size of the file to display the size of the file, as follows:
[BILLING_DX@BMCS1 bin]$ ls-lh total
565M
-rwxr-xr-x 1 billing_dx billing 1.1M Mar 18:56 acctmgrservice-rw
-r--r--1 billing_dx Billing  364 Mar 18:59 acctmgrservice.conf
-rw-------1 billing_dx billing  11G Mar 13 1 8:37 core.22836
-rw-r--r--1 billing_dx billing  410 Mar 17:38 dll_info.conf
-rwxr-xr-x 1 billing_dx BILLIN G-   18:57 Go



When you use the "-H" parameter, the unit selected to display is "K", "M", or "G", depending on the size of the file. If you want to specify the units to display, you can use the "--block-size" argument as follows:

[BILLING_DX@BMCS1 bin]$ ls-l total 577724-rwxr-xr-x 1 billing_dx billing 1103862 Mar 18:56 r--1 billing_dx Billing 364 Mar 18:59 acctmgrservice.conf-rw-------1 billing_dx billing 10947788800 Mar 13 1          8:37 core.22836-rw-r--r--1 billing_dx billing 410 Mar 17:38 dll_info.conf-rwxr-xr-x 1 billing_dx Billing     18:57 go [billing_dx@bmcs1 bin]$ ls-l--block-size=k total 577724k-rwxr-xr-x 1 billing_dx Billing 1078K Mar 18:56 acctmgrservice-rw-r--r--1 billing_dx billing 1K Mar 18:59 acctmgrservice.conf-rw-------1
BILLING_DX Billing 10691200K 18:37 core.22836-rw-r--r--1 billing_dx billing 1K Mar 17:38 dll_info.conf -rwxr-xr-x 1 billing_dx billing 1K Mar 18:57 go [billing_dx@bmcs1 bin]$ ls-l--block-size=m Total 565m-rwxr-x R-x 1 billing_dx billing 2M Mar 18:56 acctmgrservice-rw-r--r--1 billing_dx billing 1M Mar 18:59 acctmgrser VICE.CONF-RW-------1 BILLING_DX Billing 10441M 18:37 core.22836-rw-r--r--1 billing_dx billing 1M Mar 17:38 dll_info.conf-rwxr-x R-x 1 billing_dx billing 1M Mar 18:57 go [billing_dx@bmcs1 bin]$ ls-l--block-size=g Total 1g-rwxr-xr-x 1 Billin G_DX billing 1G Mar 18:56 acctmgrservice-rw-r--r--1 billing_dx billing 1G Mar 18:59 ACCTMGRSERVICE.CONF-RW----- --1 billing_dx billing 11G 18:37 core.22836-rw-r--r--1 billing_dx billing 1G Mar 17:38 dll_info.conf-rwxr-x R-x 1 billing_dx billing 1G 18:57 Go



In contrast can be seen, using different units to display the time, the use of a method, so a 1k of things, using G for the unit display is, will display as "1G." Therefore, it is better to use "-H" to display, more in line with people's habits.
The following is a description of the LS display:
BILLING_DX@BMCS1 bin]$ man ls
ls (1)                            User Commands                           ls (1)


NAME
   ls-list Directory contents


Synopsis
   ls [OPTION] ... [FILE]


... DESCRIPTION
   List  information about the FILEs (the current  directory by default).  Sort entries Alphabetically if
   none Of-cftuvsux nor--sort.


   Mandatory arguments to long options are mandatory for short options too.


   -H,--human-readable
          with-l, print sizes in human readable format (e.g., 1K 234M 2G)-


   k like     --block-size= 1 k


   -l use     a long listing format


   --block-size=size use
          size-byte blocks.  The size format below size May is an  Integer optionally followed By one of the FOLLOWING:KB 1000, K 1024, MB
   1000*1000, M 1024*1024, and so in for G, T, P, E, Z, Y.



Extended reading:  http://hi.baidu.com/shiliangshuai/item/2310fac2ce7aa3bb0c0a7b3f 

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.