Skip to content

Instantly share code, notes, and snippets.

@lopes
Last active December 18, 2015 01:19
Show Gist options
  • Save lopes/5702664 to your computer and use it in GitHub Desktop.
Save lopes/5702664 to your computer and use it in GitHub Desktop.
Packs an entire directory by zipping and encrypting it.
#!/bin/bash
#pack.sh
#
# Zips and crypts a directory.
#
# TODO
# - Ask confirmation before delete.
##
OUTPUT="$(basename $(pwd))" #current dirname
cd ..
tar -czvf "${OUTPUT}.tgz" "${OUTPUT}"
gpg --symmetric --cipher-algo aes256 "${OUTPUT}.tgz"
if [ "$?" == "0" ]; then
rm -rf "${OUTPUT}.tgz"
echo "REMEMBER TO DELETE THE ORIGINAL FILES!"
fi
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment