超实用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]#
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]#
相关文章推荐
- 妈咪,我找到了!15实用的Linux find命令示例
- Cheat : 一个实用 Linux 命令示例集合 | Linux 中国
- linux 的重定向、管道、xargs 命令
- 15个实用的Linux find命令示例
- Linux 中 17 个 tar 命令实用示例
- 30个实用的Linux find命令示例
- 8 个实用的 Linux netcat 命令示例
- Linux 中 17 个 tar 命令实用示例
- [linux学习笔记]第3天:变量分类,重定向,管道命令,程序执行流,文本处理类命令, 正则表达式,短路操作符
- 8 个实用的 Linux netcat 命令示例
- 30个实用的Linux find命令示例
- linux xargs命令的使用及其与exec、管道的区别
- 妈咪,我找到了! -- 15个实用的Linux find命令示例
- 8个实用的Linux netcat命令示例
- [shell]妈咪,我找到了! -- 15个实用的Linux find命令示例
- 15个实用的Linux find命令示例
- Linux中的Xargs命令,支持|管道传递参数
- 8个实用的Linux netcat命令示例
- Linux中很多命令不支持|管道来传递参数解决方法 -- xargs
- Linux中文本处理命令sed的使用示例分享