Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why does xargs strip quotes from input text?

Here is a simplified example:

echo "/Place/='http://www.google.com'" | 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
up vote 4 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/=\'http://www.google.com\'" | xargs echo

will work but echo /Place/=\'http://www.google.com\' | xargs echo will not.

share|improve this answer
Nothing against down votes but a comment on the reason would help :-) – Matteo Apr 20 '15 at 5:35
What if you're piping in input? If I have a script that outputs "/Place/='http://www.google.com'", how can I properly escape it? – Roger Filmyer Jul 7 '15 at 21:19
@RogerFilmyer your_script | parallel --shellquote | ... – Ole Tange Apr 18 at 12:40

You could use GNU Parallel instead:

$ echo "/Place/='http://www.google.com'" | parallel echo

Then you do not have to do the quoting yourself.

Learn more: https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1

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.