2

I'm trying to encrypt a bunch of files with the code below:

find . -name "*.vi" | sort | parallel --gnu -j 4 --workdir "$PWD" '
    echo "Encrypting {/.} ..."
    gpg -r [email protected] -o "/tank/test/{/.}.gpg" -e "{}"
';

This works fine, but only if the filenames have no spaces nor special characters (! or ') in them. Other than re-naming all the files, is there a way to make this code work?

0

1 Answer 1

2

It looks like too much quoting. Remember that GNU Parallel assumes {} is being parsed directly by the shell. Try removing "" around {} and {/.}:

# Avoid typing --gnu ever again
echo '--gnu' >> ~/.parallel/config

find . -name "*.vi" | sort |
  parallel echo Encrypting {/.} ...";" gpg -r [email protected] -o /tank/test/{/.}.gpg -e {}
2
  • Works! The resulting filenames have their spaces replaced by "\" but that's no problem, i can just run a rename command after that. Thanks man!
    – Weekender
    May 29, 2015 at 20:05
  • Then you have not removed enough ". Remove more. Remember {} and {/.} should never be inside " or '.
    – Ole Tange
    May 29, 2015 at 20:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .