Search code examples
echoxargs

xargs lines containing -e and -n processed differently


When running the following command with xargs (GNU findutils) 4.7.0

xargs -n1 <<<"-d -e -n -o"

I get this output

-d

-o

Why is -e and -n not present in the output?


Solution

  • From man xargs:

    [...] and executes the command (default is /bin/echo) [...]

    So it runs:

    echo -d
    echo -e
    echo -n
    echo -o
    

    But from man echo:

    -n     do not output the trailing newline
    
    -e     enable interpretation of backslash escapes
    

    And echo -n outputs nothing, and echo -e outputs one empty newlines that you see in the output.