Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Why does xargs strip quotes from input text?

Here is a simplified example:

echo "/Place/=''" | xargs echo



Is there any way to work-around this? (xargs -0 doesn't help me)

share|improve this question
xargs treats quotes and backslashes specially as part of the spec. Post what you are trying to do with xargs instead. – jw013 May 8 '12 at 13:31
xargs -0 works for me here... Why doesn't it help you? – derobert Apr 8 '13 at 16:24

2 Answers 2

up vote 2 down vote accepted

From the xargs manual:

If you want an input argument to contain blanks or horizontal tabs, enclose it in double quotes or apostrophes. If the argument contains a double quote character ("), you must enclose the argument in apostrophes. Conversely, if the argument contains an apostrophe ('), you must enclose the argument in double quotes. You can also put a backslash (\) in front of a character to tell xargs to ignore any special meaning the character may have (for example, white space characters, or quotes).

This means you can escape quotes if the quotes are quoted themselves:

$ echo "/Place/=\'\'" | xargs echo

will work but echo /Place/=\'\' | xargs echo will not.

share|improve this answer
Nothing against down votes but a comment on the reason would help :-) – Matteo Apr 20 at 5:35
What if you're piping in input? If I have a script that outputs "/Place/=''", how can I properly escape it? – Roger Filmyer Jul 7 at 21:19

You could use GNU Parallel instead:

$ echo "/Place/=''" | parallel echo

Then you do not have to do the quoting yourself.

Learn more:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.