Useful Linux File Management Commands

Here’s a list of commands I use or automate every day to deal with various file management tasks, you might find some of these useful yourself:
To remove all files over a certain age (useful for clearing out caches for example) use this:
find [path] -mtime +[integer] -exec rm {} ;
Replace [path] with the directory you want to start looking in and [integer] with the number of days you want to keep files for e.g. if [integer] is 7 the this will delete any files over 7 days old.
To remove all files of 0 bytes in length:
find [path] -type f -size 0 -exec rm {} ;
Replace [path] with the directory you want to start looking and 0 with the minimum file size you want to remove. This 0 bytes ‘trick’ is useful for removing files such as cached images which may have failed to download to your server when requested by some script or other automated process.