shell 管道符| 后面的xargs 一次执行多条命令,用xargs获取到的参数


find ./*.js|xargs -i  sh -c 'ls -l {}; cat -n {}'|vim -

这条命令不是很安全,This is insecure. What if your file.txt contains a datum with $(rm -rf ~) as a substring?

ls $(rm -rf ./*) 执行这条命令的时候,会把当前目录下面的东西全部删除!!


这台命令可以先输出文件名,然后再打印文件的内容。


cat file.txt | xargs -i sh -c 'command {} | command2 {} && command3 {}'

-----------------------------------------------------------------------------


reference: https://stackoverflow.com/questions/6958689/calling-multiple-commands-with-xargs

猜你喜欢

转载自www.cnblogs.com/oxspirt/p/12198503.html
今日推荐