xargs: unmatched single quote
OK… Here is a short tip that might help others in the same situation: here i was running a simple find/grep command that I have always used to search for files matching some string; this was something simple like:
find . -type f | xargs grep string
And bum… After a while the command failed with the error: “xargs: unmatched single quote“. This happened because one of the files returned by the find command had a quote character inside its file name. xargs was not able to distinguish between the quote part of the file name and the quote used to quote names.
If you encounter a similar problems the solutions is to add -printf ‘”%p”\n’ to the find command line that will enclose all file names into double quotes:
find . -type f -printf '"%p"\n' | xargs grep string
if your find command does not have the -printf operand, you can try to use the -print0 operand and the command will look like:
find . -type f -print0 | xargs -0 grep string
-M.
Share This








24th November 2007, 04:10
Hi Marius,
Thanks for the tip. Another tip to search a string inside the search results,
====
find . -type f -exec grep string {} \;
====
Thanks
Anil
24th November 2007, 18:18
recursive grep is nice too !
grep -R string .
10th January 2008, 06:50
find . -type f | xargs -d ‘\n’ grep string