您的位置:首页 > 运维架构 > Linux

超实用linux管道处理命令xargs的应用示例

2010-04-19 10:02 627 查看
Xargs相当于一个管道命令,具体的用法如下:

1. 首先创建一个示例文件

[root@cacti /]# mkdir -p /test

[root@cacti /]# cd /test/

[root@cacti test]# touch a b c d e f g

[root@cacti test]# ls

a b c d e f g

[root@cacti test]#

2. 把目录下的所有文件重命名为.test为后缀的

[root@cacti test]# ls |xargs -i mv {} {}.test

[root@cacti test]# ls

a.test b.test c.test d.test e.test f.test g.test

[root@cacti test]#

3. 删除所有文件

[root@cacti test]# ls |xargs -i rm {}

[root@cacti test]# ls

[root@cacti test]#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息