Linux檢視資料夾大小du

追憶丶年華發表於2018-01-25

du命令引數詳解見: http://baike.baidu.com/view/43913.htm

下面我們只對其做簡單介紹;

 

 

檢視linux檔案目錄的大小和資料夾包含的檔案數

 

 

 

統計總數大小

 

 

 

du -sh filename(其實我們經常用du -sh *,顯示當前目錄下所有的檔案及其大小,如果要排序再在後面加上 | sort -n)

 

 

du -sm * | sort -n //統計當前目錄大小 並按大小 排序

 

 

du -sk * | sort -n

 

 

du -sk * | grep filename //檢視一個資料夾的大小

 

du -m | cut -d "/" -f 2 //看第二個/ 字元前的文字

    檢視此資料夾有多少檔案 /*/*/* 有多少檔案

 

du filename/

 

du filename/*/*/* |wc -l

    40752

解釋:

    wc [-lmw]

    引數說明:

    -l :多少行

    -m:多少字元

    -w:多少字

 

 

或者也可以開啟Nautilus視窗(資料夾首選項),點選“編輯”-“首選項”,切換到“顯示”標籤,改變“圖示標題”下面的樹形列表的內容為“大小,修改日期、型別”。設定立即生效。現在在檔案圖示的下面會顯示檔案的大小。

 

PS:

 

 

df -hl 檢視磁碟剩餘空間

du -sm 檔案
返回該資料夾總M數

更多功能檢視:
df --help
du --help

du --help
用法:du [選項]... [檔案]...
總結每個<檔案>的磁碟用量,目錄則取總用量。
長選項必須用的引數在使用短選項時也是必須的。
-a, --all             write counts for all files, not just directories
      --apparent-size   print apparent sizes, rather than disk usage; although
                          the apparent size is usually smaller, it may be
                          larger due to holes in (`sparse') files, internal
                          fragmentation, indirect blocks, and the like
-B, --block-size=SIZE use SIZE-byte blocks
-b, --bytes           equivalent to `--apparent-size --block-size=1'
-c, --total           produce a grand total
-D, --dereference-args dereference FILEs that are symbolic links
-H                    like --si, but also evokes a warning; will soon
                        change to be equivalent to --dereference-args (-D)
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
      --si              like -h, but use powers of 1000 not 1024
-k                    like --block-size=1K
-l, --count-links     count sizes many times if hard linked
-L, --dereference     dereference all symbolic links
-P, --no-dereference don't follow any symbolic links (this is the default)
-0, --null            end each output line with 0 byte rather than newline
-S, --separate-dirs   do not include size of subdirectories
-s, --summarize       display only a total for each argument
-x, --one-file-system skip directories on different filesystems
-X FILE, --exclude-from=FILE Exclude files that match any pattern in FILE.
      --exclude=PATTERN Exclude files that match PATTERN.
      --max-depth=N     print the total for a directory (or file, with --all)
                          only if it is N or fewer levels below the command
                          line argument; --max-depth=0 is the same as
                          --summarize
      --help     顯示此幫助資訊並離開
      --version 顯示版本資訊並離開

eg: du -smh oracle
54G    //顯示oracle資料夾的大小為54G

相關文章