Skip to content

Instantly share code, notes, and snippets.

@carlynorama
Created February 15, 2014 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlynorama/9026262 to your computer and use it in GitHub Desktop.
Save carlynorama/9026262 to your computer and use it in GitHub Desktop.
Finding files that are too new (less than a year old) and removing them.
# (find) in this directory (.) items of (-type) file (f) whose last modification (-mtime) was less than 365 days ago (-365)
# pipe the result into a file called newfiles.txt
find . -type f -mtime -365 > newfiles.txt
#look at newfiles.txt
cat newfiles.txt
#if everything listed is a malicious file
#run the find again, but instead of outputing to file
#run as a subprocess (-exec) the remove command (rm) on each result ({})
#terminate the exec called subrocess (\; , where the \ escapes the required ;)
find . -type f -mtime -365 -exec rm {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment