Search code examples
gnu-parallel

`-a` vs. `cat`ting in GNU Parallel


When trying to process, for example, 128 bytes of a file at a time, this works:

cat input.dat | parallel --pipe --recend '' -k --block-size 128 "<command>" > output.dat

But this

parallel -a input.dat --pipe --recend '' -k --block-size 128 "<command>" > output.dat

throws an error:

parallel: Warning: A NUL character in the input was replaced with \0.
parallel: Warning: NUL cannot be passed through in the argument list.
parallel: Warning: Did you mean to use the --null option? 

Why?


Solution

  • The difference comes from how parallel handles input:

    1. cat input.dat | parallel ...:
      Piping the content (data) direct will treat it as a stream, with --pipe splitting it into chunks without interpreting NUL characters.

    2. parallel -a input.dat ...:
      The -a option reads input.dat as a list of arguments, where NUL characters cause warnings unless --null is used.

    To fix the the issue with -a, use:

    parallel -a input.dat --pipe --recend '' -k --block-size 128 --null "<command>" > output.dat