Removing files that used most space
By yuli - Posted on May 4th, 2008
Today I had the following problem. One of the production servers when out of free disk space. I had to delete few big files and directories. I decided to compose this post to cover basic steps you can use to find files that use the most space.
I use the following command to find disk usage of the existing directory:
du -ch ./
- -c - produce a grand total
- -h - print sizes in human readable format (e.g., 1K 234M 2G)
In case you have too many files, you can redirect the output to a file like the following:
du -ch ./ > result.txt
Next step is to filter directories and find those wich use most of the space.
I used the following simple regular expression to filter those records had GB size.:
cat result.txt | grep -E [0-9]G












BTW, You don't have to write it to a file first... Just pipe it to grep... ;>)
[root@me ~]# du -ch / | grep -E [0-9]G
1.4G /usr/share
1.9G /usr/a
1.9G /usr/b
4.9G /usr
16G /backup/c
17G /backup
24G /
24G total
[root@me ~]#
Cheers,
Dan