Skip to content

Instantly share code, notes, and snippets.

@stekan
Created August 7, 2017 18:05
Show Gist options
  • Save stekan/a1adc322157b9af5e0dcc3142bb4b90f to your computer and use it in GitHub Desktop.
Save stekan/a1adc322157b9af5e0dcc3142bb4b90f to your computer and use it in GitHub Desktop.
Find gpg email and decrypt
#!/bin/bash
SRC=/path/to/eml/src
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
cd "$SRC"
for file in $(find -type f -name "*.eml" -exec grep -l "BEGIN\ PGP\ MESSAGE" {} \; -print)
do
gpg --decrypt --batch --no-tty --output "$(echo $file|sed 's/\.[^.]*$//').decrypted.eml" "$file"
done
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment