Created
March 26, 2016 06:36
-
-
Save Ohcanep/cbc3337981248afe83bd to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
E_NUMARGS=1 | |
E_NOTDIR=2 | |
if [ $# -ne 1 ]; then | |
echo "Usage: `basename $0` [DIRECTORY]" | |
exit $E_NUMARGS | |
fi | |
if [ ! -d $1 ]; then | |
echo "No such directory" | |
exit $E_NOTDIR | |
fi | |
suffix=$(date +%Y-%m-%dT%H-%M-%S%z)".tar.gz" | |
filename="$1_$suffix" | |
echo "Archiving $1 ..." | |
tar -cvzf $filename $1 | |
if [ $? -eq 0 ]; then | |
echo "Archive $filename created." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment