tag: find

Delete files based on last modified date

3 Oct, 2011 - 1 minutes
First create some files to test with: touch -d 01/01/2015 newfile touch -d 01/01/2009 oldfile Check it worked. using ls -l osaka@rika:~/test$ ls -l total 0 -rw-r--r-- 1 osaka osaka 0 Jan 1 2015 newfile -rw-r--r-- 1 osaka osaka 0 Jan 1 2009 oldfile And now delete all files which where last modified over one year ago. find . -mtime +360 -delete The same as; find /home/osaka/test/ -mtime +360 -exec rm '{}' \; Enojy.

Find Command

6 May, 2011 - 1 minutes
The find command is very useful for organizing your files and folders, or in combination with bash scripting. For example I had an mp3 player which would only play mp3s that were not inside a directory. Now all my music is located inside sub-directories, so I could spend most of my day moving them out, or I could use the find command. find . -iname \*.mp3 -type f -exec cp {} .