When the file size is displayed in linux, "ls-l" is usually used to display the file size in bytes.
However, if the file is large, it is not particularly readable. In this case, you can use "ls-lh" to display the file size in a unit close to the file size, as follows:
[billing_dx@bmcs1 bin]$ ls -lhtotal 565M-rwxr-xr-x 1 billing_dx BILLING 1.1M Mar 10 18:56 AcctMgrService-rw-r--r-- 1 billing_dx BILLING 364 Mar 10 18:59 AcctMgrService.conf-rw------- 1 billing_dx BILLING 11G Mar 13 18:37 core.22836-rw-r--r-- 1 billing_dx BILLING 410 Mar 13 17:38 dll_info.conf-rwxr-xr-x 1 billing_dx BILLING 39 Mar 10 18:57 go
When the "-h" parameter is used, the displayed unit is "K", "M", or "G" based on the file size ". If you want to specify the display unit, you can use the "-- block-size" parameter, as shown below:
[billing_dx@bmcs1 bin]$ ls -ltotal 577724-rwxr-xr-x 1 billing_dx BILLING 1103862 Mar 10 18:56 AcctMgrService-rw-r--r-- 1 billing_dx BILLING 364 Mar 10 18:59 AcctMgrService.conf-rw------- 1 billing_dx BILLING 10947788800 Mar 13 18:37 core.22836-rw-r--r-- 1 billing_dx BILLING 410 Mar 13 17:38 dll_info.conf-rwxr-xr-x 1 billing_dx BILLING 39 Mar 10 18:57 go[billing_dx@bmcs1 bin]$ ls -l --block-size=k total 577724K-rwxr-xr-x 1 billing_dx BILLING 1078K Mar 10 18:56 AcctMgrService-rw-r--r-- 1 billing_dx BILLING 1K Mar 10 18:59 AcctMgrService.conf-rw------- 1 billing_dx BILLING 10691200K Mar 13 18:37 core.22836-rw-r--r-- 1 billing_dx BILLING 1K Mar 13 17:38 dll_info.conf-rwxr-xr-x 1 billing_dx BILLING 1K Mar 10 18:57 go[billing_dx@bmcs1 bin]$ ls -l --block-size=mtotal 565M-rwxr-xr-x 1 billing_dx BILLING 2M Mar 10 18:56 AcctMgrService-rw-r--r-- 1 billing_dx BILLING 1M Mar 10 18:59 AcctMgrService.conf-rw------- 1 billing_dx BILLING 10441M Mar 13 18:37 core.22836-rw-r--r-- 1 billing_dx BILLING 1M Mar 13 17:38 dll_info.conf-rwxr-xr-x 1 billing_dx BILLING 1M Mar 10 18:57 go[billing_dx@bmcs1 bin]$ ls -l --block-size=gtotal 1G-rwxr-xr-x 1 billing_dx BILLING 1G Mar 10 18:56 AcctMgrService-rw-r--r-- 1 billing_dx BILLING 1G Mar 10 18:59 AcctMgrService.conf-rw------- 1 billing_dx BILLING 11G Mar 13 18:37 core.22836-rw-r--r-- 1 billing_dx BILLING 1G Mar 13 17:38 dll_info.conf-rwxr-xr-x 1 billing_dx BILLING 1G Mar 10 18:57 go
After comparison, we can see that when different units are used for display, we use the one-in-one method. Therefore, for a 1 K object, G is used for display, it is displayed as "1 GB ". Therefore, we still use "-h" to display it, which is more in line with people's habits.
The following is the description of ls:
billing_dx@bmcs1 bin]$ man lsLS(1) User Commands LS(1)NAME ls - list directory contentsSYNOPSIS 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=1K -l use a long listing format --block-size=SIZE use SIZE-byte blocks. See SIZE format below SIZE may be (or may be an integer optionally followed by) one of following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
Additional reading: http://hi.baidu.com/shiliangshuai/item/2310fac2ce7aa3bb0c0a7b3f