Recently I needed to do some cleaning up of some temporary files on one of my web servers so I came up with this find command
find . -mtime +1 -type f -printf '%p %Ax\n'
this command will list files in the current directory that where last modified more than 24 hours ago, when printing out the file names it will also print out the date the file was last modified.
find . -mtime +1 -type f -printf '%AY-%Am-%Ad %AT %p\n' | sort
makes use of some more conditions within the printf and the sort command. By putting the date on the front of each entry which is printed out and using the sort command the files are printed in chronological order.
find . -mtime +0 -type f -print0 | xargs -0 du -csh
is the final example I will give this time which combines using find with xargs and du in order to find the disk usage of all the files that match the find condition.
Recent Comments