Reputation: 4411
I am using xargs
to search a content in a file but xargs
fails because of whitespace in file name. What is the reason behind this? Anyway, I can acheive it by using -exec
in the find
command.
Upvotes: 0
Views: 1099
Reputation: 15603
When using find
and xargs
on files that may contain whitespace, use -print0
with find
and -0
with xargs
, that way xargs
receives the file names separated by nul
instead and will call the utility with the correct arguments.
For example, looking for "string" in all files in the current directory (and below):
$ find . -type f -print0 | xargs -0 grep "string"
See the manuals for both find
and xargs
.
Upvotes: 2