linux 中du命令指定以不同的单位显示文件的大小

发布时间 2023-11-25 18:03:02作者: 小鲨鱼2018

 

001、

(base) [root@pc1 test]# ls
(base) [root@pc1 test]# dd if=/dev/zero of=a.txt count=30 bs=1M     ## 生成一个测试文件
30+0 records in
30+0 records out
31457280 bytes (31 MB) copied, 0.0231627 s, 1.4 GB/s
(base) [root@pc1 test]# ll -h                                   ## 查看该文件
total 30M
-rw-r--r--. 1 root root 30M Nov 25 17:47 a.txt
(base) [root@pc1 test]# du -b a.txt                             ## bp
31457280        a.txt
(base) [root@pc1 test]# du -k a.txt                             ## kb
30720   a.txt
(base) [root@pc1 test]# du -m a.txt                             ## mb
30      a.txt
(base) [root@pc1 test]# du -h a.txt                             ## 人类友好可读
30M     a.txt

 。