linux - GNU Parallel - redirect output to a file with a specific name -


in bash running gnupg decrypt files , output redirected file having same name, different extension. basically, if file named

file1.sc.xz.gpg 

the file comes out after running gnupg tool stored inside file called

file1.sc.xz  

i trying

find . -type f | parallel "gpg {} > {}.sc.xz" 

but results in file called file1.sc.xz.gpg.sc.xz. how can this?

later edit: inside 1 single bash command, without knowing filename in advance.

you can use bash variable expansion chop off extension:

$ f=file1.sc.xz.gpg $ echo ${f%.*} file1.sc.xz 

e.g.:

find . -type f | parallel bash -c 'f="{}"; g="${f%.*}"; gpg "$f" > "$g"' 

alternatively, use expansion of parallel:

find . -type f | parallel 'gpg "{}" > "{.}"' 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -