Last active
September 12, 2018 02:34
-
-
Save fercreek/4935441973bf6c33fcd6ba6a54fa3f7e to your computer and use it in GitHub Desktop.
SimpleBackup.sh
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 | |
# input: file or folder | |
# output: file with .bak ext or folder tar.gz ext | |
main(){ | |
input=${1} | |
if [[ -f ${input} ]]; then | |
# copy file | |
cp ${input} "${1%.*}-$(date +%s).bak" | |
# Copying file without extension | |
echo "It's a file" | |
elif [[ -d ${input} ]]; then | |
# Zipping with tar dependency | |
tar czf "${input}-$(date +%s).tar.gz" ${input} | |
echo "It's a directory" | |
fi | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment