用途

  • 处理标准输出 stdout
  • 转化成合适的格式
  • 再传递给另一个命令

简单使用

1
find . -links 1 -type f |xargs ls -l
  • xargs 直接后跟命令

与 find -exec your_command {} \; 比较

xargs 更快速

xargs 一次传输所有参数

find -exec {} \; 一次传输一个参数

-t 打印 执行的命令

-p 打印 执行的命令 和 “执行的用户”

-I 执行多条命令

1
  cat foo.txt | xargs -I % sh -c 'echo %; mkdir %'
  • -I R your_command

    • R

      • 后面出现的地方,被替换为参数