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 user@myemail.com -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?

Weekender
  • 45
  • 6

1 Answers1

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 user@myemail.com -o /tank/test/{/.}.gpg -e {}
Ole Tange
  • 4,529
  • 2
  • 34
  • 51
  • 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 '15 at 20:05
  • Then you have not removed enough ". Remove more. Remember {} and {/.} should *never* be inside " or '. – Ole Tange May 29 '15 at 20:45