Nov 18, 2009

Playing with "find" and "dc"


First, here is how to find and print all files that were modified more than 300 days from now, and that are bigger than 30k. For all these files we print : User [tab] Size_in_kb [tab] Creation_date [tab] Access_date [tab] Path_to_the_file

find . -mtime +300 -size +30k -type f -printf "%u\t%k\t%TD\t%AD\t%p\n"
Now, another interesting thing could be knowing the total size of all these files. For that, print only the size, followed by "+p" and pipe it to dc :

find . -mtime +300 -size +30k -type f -printf "%k+p\n" | dc
At the end you'll have the total size of your files older than 300 days, and bigger than 30kb.

No comments: