Skip to content

Instantly share code, notes, and snippets.

@sureshnath
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save sureshnath/d099982f0f06ba8ada60 to your computer and use it in GitHub Desktop.

Select an option

Save sureshnath/d099982f0f06ba8ada60 to your computer and use it in GitHub Desktop.
unix remove files currently not active and find and remove files modified n days ago
# remove files in the current directory, which are currently not in use
for file in `ls -1`; do fuser $file; if [ $? != '0' ]; then rm -f $file; fi; done
# remove files modified 3 days ago
find -type d -mtime +3 -exec rm -rf {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment