Find big directories using du and egrep

findHere’s a simple script I’m using to locate big directories (larger than 1GB):

du -h | grep "^ *[0-9][0-9.]*G"

Alternative is ncdu

apt install ncdu

run: ncdu

NCurses Disk Usage

Ncdu is a disk usage analyzer with an ncurses interface. It is designed to find space hogs on a remote server where you don’t have an entire graphical setup available, but it is a useful tool even on regular desktop systems. Ncdu aims to be fast, simple and easy to use, and should be able to run in any minimal POSIX-like environment with ncurses installed.

The output looks like this:

1.1G ./Art/2007
2.5G ./Art/2008/Party Freakz Pasta Party
6.3G ./Art/2008
9.2G ./Art
24G ./Documents/Parallels/Windows 7.pvm/Windows 7-0.hdd
24G ./Documents/Parallels/Windows 7.pvm
24G ./Documents/Parallels
26G ./Documents
2.5G ./Downloads/enstrophy-big-endian
33G ./Downloads
...
100G .

Here’s how I find big directories greater than 100MB:


du -h | egrep "^ *([0-9][0-9][0-9][0-9.]*M)|([0-9][0-9.]*G)"

To list files, too, just add the -a flag to du like this:


du -ah | grep "^ *[0-9][0-9.]*G"

Laat een reactie achter

Je e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *