How to compress all files in the current directory using lz4 using GNU parallel?
I try ls | parallel lz4 but it outputs to stdout. Why? How to fix?
How to compress all files in the current directory using lz4 using GNU parallel?
I try ls | parallel lz4 but it outputs to stdout. Why? How to fix?
Use the -m option for multiple input files (implies automatic output filenames).
ls | parallel lz4 -m
but it outputs to
stdout. Why? How to fix?
The answers are in the man page...
Why it outputs to stdout:
• When no destination is specified, result is sent on implicit output, which depends on stdout status. When stdout is Not the
console, it becomes the implicit output. Otherwise, if stdout is the console, the implicit output is filename.lz4.
In this particular case (parallel runs lz4) the stdout is not the console (see steeldriver's answer HERE); also, if you check your output it contains warning(s):
Warning : using stdout as default output. Do not rely on this behavior: use explicit `-c` instead !
How to fix (next paragraph in the man page):
• It is considered bad practice to rely on implicit output in scripts. because the script's environment may change. Always use
explicit output in scripts. -c ensures that output will be stdout. Conversely, providing a destination name, or using -m en‐
sures that the output will be either the specified name, or filename.lz4 respectively.
So the proper way would be to either provide a destination name
parallel lz4 {} {}.lz4 ::: ./*
or use the -m switch (same result but no verbosity):
parallel lz4 -m ::: ./*