xargs与find经常结合来进行文件操作,平时删日志的时候只是习惯的去删除,比如 # find . -type f -name "*.log" | xargs rm -rf * 就将以log结尾的文件删除了,如果我想去移动或者复制就需要使用参数来代替了。

xargs -i 参数或者-I参数配合{}即可进行文件的操作。 -I replace-str Replace occurrences of replace-str in the initial-arguments with names read from standard input. Also, unquoted blanks do not terminate input items; instead the separator is the newline character. Implies -x and -L 1. --replace[=replace-str], -i[replace-str] This option is a synonym for -Ireplace-str if replace-str is specified, and for -I{} otherwise. This option is deprecated; use -I instead. man了一下看的还是不太懂,通过例子,做作实验将我的理解写一下。

[root@jstuz6zw4s2vwp tmp]#ls


[root@jstuz6zw4s2vwp tmp]# find . -type f -name "*.log" | xargs -i cp {} /tmp/k/


[root@jstuz6zw4s2vwp tmp]# find . -type f -name "*.log" | xargs -I {} cp {} /tmp/n/


结果出来了,
加-i 参数直接用 {}就能代替管道之前的标准输出的内容;
加 -I 参数 需要事先指定替换字符。

最新文章

  1. iOS 隐藏自定义tabbar
  2. JTA 深度历险 - 原理与实现
  3. yum报错: Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
  4. [记录]firefox繁体转换成简体的油猴脚本
  5. jta.properties transactions.properties Log already in use 解决方法
  6. Gridheh 垂直居中
  7. POJ1321 棋盘问题(dfs)
  8. html css js 框架
  9. Spring-----Assert断言工具类
  10. hdu 4691 Front compression (后缀数组)
  11. 前后端分离之Web前端架构设计
  12. 解决jQuery和其他库冲突
  13. A1105. Spiral Matrix
  14. Study 8 —— 行块元素及定位
  15. f5双机配置
  16. java把map转json
  17. 大数据-spark HA集群搭建
  18. Dictionary tabPage使用
  19. iOS-使用添加的花样字体
  20. 2017中国大学生程序设计竞赛 - 女生专场(dp)

热门文章

  1. Mysql Innodb 引擎优化 参数(innodb_buffer_pool_size)
  2. Struts标签库详解,非常好的Struts标签详解
  3. HDU - 5942 :Just a Math Problem (莫比乌斯)
  4. 数位DP新识
  5. BZOJ2936 Codevs3634 POI1999 积水 【并查集】*
  6. BZOJ1026 SCOI2009 windy数 【数位DP】
  7. ubuntu下Python的安装和使用
  8. 字符编码:ASCII,Unicode和UTF-8
  9. Epub格式的电子书——文件组成
  10. java 乐观锁CAS