xargs - a reconstruction tool of standard input

linux管道工具集中一个相当有用的小tool,从名字中即可看出,主要是从来处理标准输入中的arguments,可以对一批arguments进行重组,提示,位置替换等功能。(为何要重组:和shell命令一次最多能处理多少argument有关,替换可以使命令更加灵活)

 

标准用法:

xargs [options] [command ]

 

适用场景 :配合ls、find等使用

Options

Option Description
-n# Execute command once for every # argument. For example, -n2 bundles arguments into groups of two or less and executes command on each argument bundle.
-l# Execute command once for every # lines of input. For example, -l1 creates a bundle of arguments for every one line of input and executes command on each argument bundle.
-i Normally xargs places input arguments at the end of command . Used with the -i option, xargs will replace all instances of {} with input arguments. You need to put them in single brackets or use a backslash (/) before each bracket to keep the shell from interpreting the special characters.
-t Echo each command before executing. Nice for debugging
-p Prompts the user before executing each command . Useful for debugging.

Examples

ls | xargs -i{} mv {} {}.old

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值