ls显示文件大小时显示单位
在Linux中显示文件大小的时候,通常的做法是使用“ls -l”,显示的大小是文件的字节大小。
但是,如果文件比较大的话,显示起来不是特别易读,这个时候,可以使用“ls -lh”,就可以使用比较接近文件大小的单位显示文件的大小,如下:
[www.linuxidc.com@linux bin]$ ls -lh
total 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
使用“-h”参数时,会根据文件的大小选择显示的单位是“K”、“M”还是“G”。如果希望指定显示的单位,可以使用“--block-size”参数,如下:
[www.linuxidc.com@linux bin]$ ls -l
total 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
[www.linuxidc.com@linux 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
[www.linuxidc.com@linux bin]$ ls -l --block-size=m
total 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
[www.linuxidc.com@linux bin]$ ls -l --block-size=g
total 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
同哦过对比可以看到,使用 不同的单位显示的时候,使用的是进一法,所以一个1k的东西,使用G为单位显示的是,会显示为“1G”。所以,还是使用“-h”显示起来,更符合人的习惯。
下面是ls显示的相关描述:
[www.linuxidc.com@linux 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=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.
ls显示文件大小时显示单位的更多相关文章
- PyQt通过resize改变窗体大小时ListWidget显示异常
前几天开始的pygame音乐播放器Doco,做的差不多了,上午做到了歌词显示和搜索页面.遇到bug,即通过resize改变ui大小时ListWidget显示异常 #目的: 增加一部分窗口用来显示歌词和 ...
- android开发学习---layout布局、显示单位和如何进行单元测试
一.五大布局(layout) android中的用五大布局:LinearLayout (线性布局).AbsoluteLayout(绝对布局).RelativeLayout(相对布局).TableLay ...
- 排查在 Azure 中创建、重启 Windows VM 或调整其大小时发生的分配失败
创建 VM.重新启动已停止(解除分配)的 VM 和重设 VM 大小时,Azure 会为订阅分配计算资源. 执行这些操作时,即使尚未达到 Azure 订阅限制,也可能偶尔收到错误. 本文说明一些常见分配 ...
- 排查在 Azure 中创建、重启 Linux VM 或调整其大小时发生的分配故障
创建 VM.重启已停止(解除分配)的 VM 和重设 VM 大小时,Azure 会为订阅分配计算资源. 执行这些操作时,即使尚未达到 Azure 订阅限制,也可能偶尔收到错误. 本文说明一些常见分配故障 ...
- 显示单位px和dip以及sp的区别
显示单位px和dip以及sp的区别(转) dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA.HVG ...
- Android中的显示单位
px (pixels)像素 一般HVGA代表320x480像素,这个用的比较多. dip或dp (device independent pixels)设备独立像素 这个和设备硬件有关,一般为了支持WV ...
- DataGridView大扩展——显示行号
原文 DataGridView大扩展——显示行号 在DataGridView 的实际使用中,经常需要标示出行号,这样可以比较醒目地看到当前信息.不过DataGridView 在绘制 DataGridV ...
- js 弹窗广告24小时显示一次
弹窗24小时显示一次 https://www.w3cschool.cn/javascript/js-cookies.html 我们需要借助cookie来实现这个功能 function setcooki ...
- Android的学习之路(四)项目中清单文件的学习和android中经常使用的显示单位
1.所谓的清单文件就是项目中的AndroidManifest.xml文件.这个文件但是有大用处的.比方:app的名字,图标.app支持的版本号app的包名等等.以下我就介绍下这个清单文件的各个參数的作 ...
随机推荐
- 设置sudo权限
由于CentOS安装之后,普通用户无sudo权限,故应该设置sudo权限. 此处假设当前用户为“cloudgis”. 1. 设置sudo权限,则设置如下: $ su root 输入root 密码 $ ...
- 苹果官网 demo The Elements 阅读随笔
The Elements https://developer.apple.com/library/ios/samplecode/TheElements/Introduction/Intro.html# ...
- MySQL [Warning] Can’t create test file xxx lower-test(转)
add by zhj:修改的数据库的datadir,然后数据库就无法启动了,错误如下 2014-12-11 16:22:57 26309 [Warning] Can't create test fil ...
- 2d网络游戏的延迟补偿(Lag compensation with networked 2D games)
http://gamedev.stackexchange.com/questions/6645/lag-compensation-with-networked-2d-games ——————————— ...
- area标签circle/rect/poligon坐标
<img src="images/02.gif" title="flower" usemap="#mm" /> <map ...
- 实时监控mysql数据库变化
对于二次开发来说,很大一部分就找找文件和找数据库的变化情况 对于数据库变化.还没有发现比较好用的监控数据库变化监控软件. 今天,我就给大家介绍一个如何使用mysql自带的功能监控数据库变化 1.打开数 ...
- web.xml filter 顺序
The order the container uses in building the chain of filters to be applied for a particular request ...
- HDU 1392 Surround the Trees 构造凸包
又是一道模板题 #include <iostream> #include <cstring> #include <cstdlib> #include <cst ...
- 命令行解析getopt_long
getopt_long函数可以轻松的解析main函数的命令行参数. int getopt_long(int argc,char * const argv[],const char *optstring ...
- date之Hi时间的思考
工作中用到需要一个判断当前时间是否在 23:50到1:00之间的一段程序,在和别人的讨论中基本上有以下两种做法 1.分别获取时分进行判断和比较 <?php function check_time ...