Well, the main problem is to find the name of the directory with the larger size. After that, you can use the same find command. To easily parse the output of
du, first remove the
-h option and try something like this (using command substitution):
Code:
large_dir=$(du -s * | sort -n | awk 'END{print $2}')
This will sort numerically the size of the directories in ascending order and the awk command will extract the directory name from the last row of the output (the largest one). After that:
Code:
find $large_dir -mtime +1 -exec echo rm {} \;
Please, notice the
echo command after -exec. This is for testing purposes: you cannot risk to remove your precious data before being sure it works as expected, therefore the echo just displays the commands without actually run them. Hope this helps.