Skip to content

Instantly share code, notes, and snippets.

@balanceiskey
Created March 1, 2012 15:22
Show Gist options
  • Save balanceiskey/1950480 to your computer and use it in GitHub Desktop.
Save balanceiskey/1950480 to your computer and use it in GitHub Desktop.
Simple bash function to archive a bunch of folders
archive(){
for var in "$@"
do
if [ -z "$var" ]
then
echo "You must supply a folder to archive."
return
else
if [ -d $var ]
then
timestamp=`date -u "+%s"`
dest=$ARCHIVE_PATH"/"$timestamp"_"$var".tar.gz"
echo "$dest"
tar -zcvf "$dest" $var
rm -r $var
else
echo "You must supply a folder."
return
fi
fi
done
}
@geedew
Copy link

geedew commented Mar 1, 2012

Will 'rm -r $var' remove the folder? [rm -rf ?]

@balanceiskey
Copy link
Author

balanceiskey commented Mar 1, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment