Tags Archives: du

Track deleted (but open) file usage

From time to time the du command doesn’t match up with df. This is due to deleted files that are still held open by a process. You can total the deleted but ‘still open’ file usage: lsof | awk ‘/deleted/ {sum+=$7} END {print sum}’ Or, to simply list all the files and their processes: lsof […]

Linux: Sort disk usage with awk

Sort the output of ‘du’ in human readable format (similar to the -h switch). du -k | sort -nr | awk ‘ BEGIN { split(“KB,MB,GB,TB”, Units, “,”); } { u = 1; while ($1 >= 1024) { $1 = $1 / 1024; u += 1 } $1 = sprintf(“%.1f %s”, $1, Units[u]); print $0; } […]