I want decrypt some gpg files, output into a file. But each time gpg ask password.
for i in *.gpg; do echo $i>>~/t; gpg -d --batch $i >>~/t; done
I test --multifile and --batch, those not as my wish.
Several ways:
# gather the password into $P
stty -echo; read -r P; stty echo;
for i in *.gpg; do printf '%s\n' "$i" >> ~/t; printf '%s' | gpg -d --batch --passphrase-fd 0 "$i" >> ~/t; done
# gather the password into $P
stty -echo; read -r P; stty echo;
for i in *.gpg; do printf '%s\n' "$i" >> ~/t; gpg -d --batch --passphrase "$P" "$i" >> ~/t; done
d=$(mktemp -d)
# gather the password into a file named `p`
stty -echo; cat > "$d/p"; stty echo
for i in *.gpg; do printf '%s\n' "$i" >> ~/t; gpg -d --batch --passphrase-file "$d/p" 0 "$i" >> ~/t; done
rm -rf "$d"