If you want to use xargs
you need to tell it to process the input one line at a time (-L1
), otherwise echo
will output the entire input at once (thus mangling all input lines into a space-separated string).
xargs -0 -L1 echo < /proc/2342/environ
You don't need the redirection, though, since xargs
can read the input file directly (parameter -a
), and echo
is the default command, so you can omit that too:
xargs -0 -L1 -a /proc/2342/environ
Alternatively, you could achieve the same result by using tr
to replace null characters with newlines:
tr '\0' '\n' < /proc/2342/environ