Chinaunix首页 | 论坛 | 博客
  • 博客访问: 226762
  • 博文数量: 57
  • 博客积分: 955
  • 博客等级: 准尉
  • 技术积分: 587
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-14 13:30
文章分类

全部博文(57)

文章存档

2012年(2)

2011年(55)

分类: LINUX

2012-03-02 14:49:21

  1. xargs - build and execute command lines from standard input
  2. xargs就是把从stdin 接收到数据重新格式化,再将其作为参数提供给其他命令
  3. 利用xargs可以将多行输入转换为单行的输出; 也可以将单行输入转换为多行输出
  4. -d 可以指定定界符
  5. -n 将输入分为多行
  6. [root@master tmp]# cat ceshi.txt
  7. a b c
  8. d e f g
  9. h i j k
  10. [root@master tmp]# cat ceshi.txt | xargs
  11. a b c d e f g h i j k
  12. [root@master tmp]# cat ceshi.txt | xargs -n 2
  13. a b
  14. c d
  15. e f
  16. g h
  17. i j
  18. k
  19. 当find与xargs结合时候,就必须将-print0与find结合使用,这是为了预防文件名中的空格而设置的
  20. find . -type f -name "*.txt" -print0 | xargs -0 rm -rf
  21. (解决参数过长问题,我们可以用-n来指定每行多少参数)
  22. -i 选项告诉xargs用{}来来代替每项的名称
  23. -t 告诉xargs先打印命令然后再执行
  24. -p 使xargs具有交互性,不过鸡肋无用

阅读(1842) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

校长的马夹2012-03-03 00:42:22

挺简洁耐用的