1. 程式人生 > >liunx檢視檔案大小命令

liunx檢視檔案大小命令

stat命令

stat filepath

[email protected]:/$ stat ~/Downloads/jdk-8u60-linux-x64.tar.gz
  File: '/home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz'
  Size: 181238643       Blocks: 353984     IO Block: 4096   regular file
Device: 808h/2056d      Inode: 261742      Links: 1
Access: (0666/-rw-rw-rw-)  Uid: ( 1000/ xanarry)   Gid: ( 1000
/ xanarry) Access: 2017-02-01 17:36:43.177892508 +0800 Modify: 2015-10-02 12:43:29.853291000 +0800 Change: 2016-12-26 23:33:34.619480450 +0800 Birth: -
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

wc命令

wc -c filename 引數-c表示統計字元, 因為一個字元一個位元組, 所以這樣得到位元組數

[email protected]:/$ wc -c  ~/Downloads/jdk-8u60-linux-x64.tar.gz
181238643 /home/xanarry/Downloads/jdk-8u60-linux
-x64.tar.gz
  • 1
  • 2

du命令

du -b filepath 引數-b表示以位元組計數

[email protected]:/$ du -b  ~/Downloads/jdk-8u60-linux-x64.tar.gz
181238643       /home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz
  • 1
  • 2

或者

du -h filepath 直接得出人好識別的檔案大小

[email protected]:/$ du -h  ~/Downloads/jdk-8u60-linux-x64.tar.gz
173M    /home/xanarry/Downloads/jdk-
8u60-linux-x64.tar.gz
  • 1
  • 2

ls命令

ls -l filepath 第五列為檔案位元組數

[email protected]:/$ ls -l  ~/Downloads/jdk-8u60-linux-x64.tar.gz
-rw-rw-rw- 1 xanarry xanarry 181238643 102  2015 /home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz
  • 1
  • 2

ls -h filepath h表示human, 加-h引數得到人好讀的檔案大小

[email protected]:/$ ls -lh  ~/Downloads/jdk-8u60-linux-x64.tar.gz
-rw-rw-rw- 1 xanarry xanarry 173M 102  2015 /home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz