GNU Parallel - redirecting output to a file with a specific name
In bash I am running GnuPG to decrypt some files and I would like the output to be redirected to a file with the same name but with a different extension. Basically, if my file is called
file1.sc.xz.gpg
the file that appears after running the GnuPG tool, I would like to save it in another file named
file1.sc.xz
I am currently trying
find . -type f | parallel "gpg {} > {}.sc.xz"
but this results in file1.sc.xz.gpg.sc.xz file. How can i do this?
Further editing: I would like to do this inside a single bash command without knowing the filename in advance.
source to share
If filenames are guaranteed not to contain \ n:
find . -type f | parallel gpg {} '>' {.}
parallel gpg {} '>' {.} ::: *
If filenames may contain \ n:
find . -type f -print0 | parallel -0 gpg {} '>' {.}
parallel -0 gpg {} '>' {.} ::: *
Note that opposite GNU shell variables. Parallel replacement lines should not be specified. This will not create file 12 ", but instead 12 \" (which is not correct):
parallel "touch '{}'" ::: '12"'
They will all do the right thing:
parallel touch '{}' ::: '12"'
parallel "touch {}" ::: '12"'
parallel touch {} ::: '12"'
source to share