xargs:不匹配的单引号;默认情况下,引号对于 xargs 是特殊的,除非您使用 -0 选项

use*_*006 9 xargs

我想用命令计算主目录上的所有普通文件:

$ find ~ -type f | xargs echo | wc -w
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
Run Code Online (Sandbox Code Playgroud)

它提示

xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
Run Code Online (Sandbox Code Playgroud)

使用上有什么问题?

wal*_*tor 13

您的某些文件名似乎在其名称中带有撇号(单引号)。

幸运的是,findxargs有解决这个办法。find's-print0选项与xargs's-0选项一起生成和使用由NUL( \000) 字符分隔的文件名列表。在Linux的文件名可以包含任何字符,除了NUL/

所以,你真正想要的是:

 find ~ -type f -print0 | xargs -0 --no-run-if-empty wc -w
Run Code Online (Sandbox Code Playgroud)

阅读man find;man xargs