Created
March 1, 2012 15:22
-
-
Save balanceiskey/1950480 to your computer and use it in GitHub Desktop.
Simple bash function to archive a bunch of folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Author
balanceiskey
commented
Mar 1, 2012
via email
So, I don't know, I'm seeing mixed things about that. rm -r appears to be working for me. I consulted this I think:
http://www.westwind.com/reference/OS-X/commandline/files-folders.html
##
Sundeep Malladi
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
…On Thursday, March 1, 2012 at 9:28 AM, Drew wrote:
Will 'rm -r $var' remove the folder? [rm -rf ?]
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1950480
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment