Created
March 9, 2016 15:21
-
-
Save cyphunk/c6d7d5714b7624ff2a9e to your computer and use it in GitHub Desktop.
create a password protected zip of files
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
#!/bin/bash | |
set -e #exit on any error | |
if [ $# -lt 1 ]; then | |
echo "$0 file [file ...]" | |
exit | |
fi | |
FILE1=$(basename "$(readlink -f "$1")") | |
NAME="${FILE1%.*}" | |
test -d "$NAME" || mkdir "$NAME" | |
cp $* "$NAME/." | |
echo "Provide password for zip \"$NAME.zip\"" | |
p=$(mktemp | tr '[:upper:]' '[:lower:]'); | |
echo -e "For example: \"${p#*.}\"\n" | |
read -s -p "Password: " PASSWORD | |
zip --quiet --encrypt --password "$PASSWORD" "$NAME.zip" "$NAME"/* | |
rm -rf "$NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment