Getting error "xargs unterminated quote" when tried to print the number of lines in terminal
Does one of your filenames have a quote in it? Try something like this:
find . "(" -name "*.m" -or -name "*.h" ")" -print0 | xargs -0 wc -l
The -print0
argument tells find
to use the NULL character to terminate each name that it prints out. The -0
argument tells xargs
that its input tokens are NULL-terminated. This avoids issues with characters that otherwise would be treated as special, like quotes.
This can happen because you have a single quote in a filename somewhere...
i.e., -> '
To find the problem file, run the following in the terminal:
\find . | grep \'
and it can also happen if you have an alias for xargs setup that's causing an issue. To test if this is the case, just run xargs with a \
in front of it, e.g.
\find . | \xargs ....
The "" simply means "run the command without any aliases"