I'd like to count all the ordinary file on home directory with commands:
$ find ~ -type f | xargs echo | wc -w
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 optionIt prompts
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 optionWhat's the problem with usage?
11 Answer
It appears that some of your filenames have apostrophes (single quote) in their names.
Luckily, find and xargs have ways around this. find's -print0 option along with xargs's -0 option produce and consume a list of filenames separated by the NUL (\000) character. Filenames in Linux may contain ANY character, EXCEPT NUL and /.
So, what you really want is:
find ~ -type f -print0 | xargs -0 --no-run-if-empty wc -wRead man find;man xargs.