When I use xargs with echo, why does the output contain an extra space?
I have a small puzzler here. I'm trying to create a one-liner, where I am combining the output from two different echo commands. The result is not quite what I expect.
For example, I expect the following command to list both lines aligned. But it does not:
# echo "1 2 3" | xargs echo -e "A B C\n"
A B C
_1 2 3
Notice the extra space on the second line (denoted by the "_"). It seems as if xargs adds a space... but why?
(For others having this problem: In order to fix it, I just add the backspace sequence to echo: echo "1 2 3" | xargs echo -e "A B C\n\b" )
Consider the example:
echo filename | xargs ls
if xargs did not add a space the command would come out as
lsfilename instead of ls filename
Try that command:
$ echo "1 2 3" | xargs echo "A B C"
$ echo -n "1 2 3"; echo "A B C"
|All times are GMT -5. The time now is 02:08 AM.|