xargs的i参数
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 参数 需要事先指定替换字符。
最新文章
- iOS 隐藏自定义tabbar
- JTA 深度历险 - 原理与实现
- yum报错: Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
- [记录]firefox繁体转换成简体的油猴脚本
- jta.properties transactions.properties Log already in use 解决方法
- Gridheh 垂直居中
- POJ1321 棋盘问题(dfs)
- html css js 框架
- Spring-----Assert断言工具类
- hdu 4691 Front compression (后缀数组)
- 前后端分离之Web前端架构设计
- 解决jQuery和其他库冲突
- A1105. Spiral Matrix
- Study 8 —— 行块元素及定位
- f5双机配置
- java把map转json
- 大数据-spark HA集群搭建
- Dictionary tabPage使用
- iOS-使用添加的花样字体
- 2017中国大学生程序设计竞赛 - 女生专场(dp)
热门文章
- Mysql Innodb 引擎优化 参数(innodb_buffer_pool_size)
- Struts标签库详解,非常好的Struts标签详解
- HDU - 5942 :Just a Math Problem (莫比乌斯)
- 数位DP新识
- BZOJ2936 Codevs3634 POI1999 积水 【并查集】*
- BZOJ1026 SCOI2009 windy数 【数位DP】
- ubuntu下Python的安装和使用
- 字符编码:ASCII,Unicode和UTF-8
- Epub格式的电子书——文件组成
- java 乐观锁CAS