I have a lot of files encrypted with gpg. All files have the same password. Is it possible to use xargs to decrypt files?
ls | xargs -n 1 gpg asks for the password for every file.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Run gpg-agent or a similar program. Set up gpg to look for a running agent, as explained in the documentation. Enter the passphrase in the agent once and for all (for this session).
ls | xargs -n 1 gpg only works if your file names do not contain any special characters. Generally speaking, don't parse the output of
xargs is pointless when you want to run the program once per file. Do this instead:
for x in *.gpg; do gpg "$x"; done