linux 查看根卷文件大小

du -xh | awk '$1~/[0-9]G/  {print $0}' | sort -nk1

[hyb92@localhost ~]$ du -xh | awk '$1~/[0-9]M/ {print $0}' | sort -nk1
du: cannot access `./Desktop/testdemo/b.txt': Permission denied
1.4M ./.cache/mozilla/firefox/vr0mh3tr.default/startupCache
1.4M ./.mozilla/firefox/vr0mh3tr.default/gmp-gmpopenh264
1.4M ./.mozilla/firefox/vr0mh3tr.default/gmp-gmpopenh264/1.6
2.2M ./.cache/mozilla/firefox/vr0mh3tr.default/cache2
2.2M ./.cache/mozilla/firefox/vr0mh3tr.default/cache2/entries
2.4M ./.cache/mozilla/firefox/vr0mh3tr.default/safebrowsing
5.9M ./.cache
5.9M ./.cache/mozilla
5.9M ./.cache/mozilla/firefox
5.9M ./.cache/mozilla/firefox/vr0mh3tr.default
16M ./.mozilla
16M ./.mozilla/firefox
16M ./.mozilla/firefox/vr0mh3tr.default
23M .

 

 

du -xh 

第一个首先获取根卷的全部相关文件夹大小

[hyb92@localhost ~]$ du -xh
4.0K ./Music
8.0K ./.dbus/session-bus
12K ./.dbus
8.0K ./.gconf/desktop/gnome/accessibility/keyboard
12K ./.gconf/desktop/gnome/accessibility
8.0K ./.gconf/desktop/gnome/peripherals/keyboard/host-bogon/0
12K ./.gconf/desktop/gnome/peripherals/keyboard/host-bogon
16K ./.gconf/desktop/gnome/peripherals/keyboard
20K ./.gconf/desktop/gnome/peripherals
36K ./.gconf/desktop/gnome
40K ./.gconf/desktop

awk '$1~/[0-9]G/  {print $0}' 

通过awk获取匹配的占用空间较大的文件夹信息

sort -nk1

 

posted @ 2019-01-19 15:59  迷糊小财迷  阅读(278)  评论(0编辑  收藏  举报