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; doneI test --multifile and --batch, those not as my wish.
How can I input password only once when gpg decrypt files in batch
password;gpg
Several ways:# gather the password into $Pstty -echo; read P; stty echo; for i in *.gpg; do echo $i >> ~/t; printf '%s' | gpg -d --batch --passphrase-fd 0 $i >> ~/t; done# gather the password into $Pstty -echo; read P; stty echo; for i in *.gpg; do echo $i >> ~/t; gpg -d --batch --passphrase $P $i >> ~/t; doned=$(mktemp -d)# gather the password into a file named `p`stty -echo; cat > $d/p; stty echofor i in *.gpg; do echo $i >> ~/t; gpg -d --batch --passphrase-file $d/p 0 $i >> ~/t; donerm -rf $d