Skip to content

Instantly share code, notes, and snippets.

@myusuf3
Created April 12, 2011 19:00
Show Gist options
  • Save myusuf3/916148 to your computer and use it in GitHub Desktop.
Save myusuf3/916148 to your computer and use it in GitHub Desktop.
bashfu - shift command
#!/bin/bash
# This script can clean up files that were last accessed over 365 days ago.
USAGE="Usage: $0 dir1 dir2 dir3 ... dirN"
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 1
fi
while (( "$#" )); do
if [[ $(ls "$1") == "" ]]; then
echo "Empty directory, nothing to be done."
else
find "$1" -type f -a -atime +365 -exec rm -i {} \;
fi
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment