Skip to content

Instantly share code, notes, and snippets.

@lopes
Last active August 7, 2024 13:34
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. #shell #shellscript #cryptography #files
#!/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