`

xargs的i参数

 
阅读更多

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


man了一下看的还是不太懂,通过例子,做作实验将我的理解写一下。 ############### 操作的目录下的文件###############[root@test05 ab]# ls
1kk.zip  3kk.zip  5kk.zip  b.rar  d.rar  f.rar  h.rar  j.rar  mini.txt  ni.txt
2kk.zip  4kk.zip  a.rar    c.rar  e.rar  g.rar  i.rar  k.rar  nii.txt###################使用 i 参数 ##################
[root@test05 ab]# find . -type f -name "*.txt" | xargs -i cp {}  /tmp/k/
[root@test05 ab]# ls ../k/
mini.txt  nii.txt  ni.txt
[root@test05 ab]# ###################  使用 I  参数 ################
[root@test05 ab]# find . -type f -name "*.txt" | xargs -I {} cp {}  /tmp/n/
[root@test05 ab]# ls ../n/
mini.txt  nii.txt  ni.txt 


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

分享到:
评论

相关推荐

    xargs命令 过滤器

    xargs命令是给其他命令传递参数的一个过滤器,也是组合多个命令的一个工具。它擅长将标准输入数据转换成命令行参数,xargs能够处理管道或者 stdin 并将其转换成特定命令的命令参数。 xargs也可以将单行或多行文本...

    linux中xargs命令的各种使用技巧

    xargs是给命令传递参数的一个过滤器,也是组合多个命令的一个工具。下面这篇文章主要给大家介绍了关于linux中xargs命令用法的相关资料,需要的朋友可以参考借鉴,下面来跟着小编一起看看吧。

    github-to-bitbucket:一组用于将 repos 从 GitHub 迁移到 BitBucket 的脚本

    GitHub 到 BitBucket:迁移工具 一组用于将 repos 从 github 迁移到 bitbucket 的 bash 脚本。 私人回购的理想选择。 设置 确保您的~/.netrc包含以下凭据: ... cat repos.txt | xargs -I {} ./bitb

    LINUX与UNIX_Shell编程指南

    第2章使用find和xargs ? find命令选项。 ? 使用f i n d命令不同选项的例子。 ? 配合f i n d使用x a rg s命令的例子。 第3章后台执行命令 ? 设置c r o n t a b文件,并用它来提交作业。 ? 使用a t命令来提交作业。 ? ...

    pygments-from-tmtheme:从 http 获取 tmtheme 文件(Sublime Color Schemes)

    tmTheme 到 Pygment 样式 (CSS) 这是一个愚蠢的脚本,它在提取 textmate/sublime 颜色主题方面做出了“最佳尝试”,并将它们转换为与 Jekyll 和 ... -name '*.tmTheme' | sed 's/\.tmTheme$//' | xargs -I FILE_NAME py

    cush-shell:一次性外壳脚本

    @ cush / shell ... ls | xargs -I {} echo {} ` const proc = shell ( script , ( stdout , stderr ) => { // This callback is optional. // See @cush /exec docs for more info. } ) // You can aw

    Linux课程教学实习要求

    两个操作数和一个运算符由位置参数给出 在屏幕上分别显示操作数、运算符和运算结果. (8)按照运行结果编写Shell程序: (9)逆序输出一个字符串 (10)冒泡法对10个数按升序排序 (11)编写1个menu的Shell程序。 #!...

    Linux高级bash编程

    A Detailed Introduction to I/O and I/O Redirection F. Standard Command-Line Options G. Important Files H. Important System Directories I. Localization J. History Commands K. A Sample .bashrc File L. ...

    Advanced Bash-Scripting Guide <>

    A Detailed Introduction to I/O and I/O Redirection F. Standard Command-Line Options G. Important Files H. Important System Directories I. Localization J. History Commands K. A Sample .bashrc File L. ...

    数据库项目组日常运维及应急故障处理手册.docx

    $ ps -ef|grep $ORACLE_SID| grep LOCAL=NO | grep -v grep |awk '{print $2}'|xargs -i kill -9 {} Windows: SQL&gt; select 'orakill ' || (select value from v$parameter where name = 'instance_name') || '...

    代码语法错误分析工具pclint8.0

    arguments: $(FileDir) -name *.c -o -name *.cpp | C:\unix\usr\local\wbin\xargs lint-nt -i"c:\unix\usr\local" -u c:\pclint\std.lnt c:\pclint\env-vc6.lnt (iii)Use Output Window打上勾,close退出。好了,...

    RED HAT LINUX 6大全

    2.3.2 内核参数选项 8 2.3.3 安装程序 9 2.3.4 选择一种安装方法 9 2.3.5 光盘安装 10 2.4 硬件配置 14 2.4.1 选择鼠标 14 2.4.2 配置X Window系统 14 2.4.3 配置网络 14 2.4.4 设置时区 15 2.4.5 选择服务自动启动 ...

    CentOS7.2.1511 gcc4.8.5 通过编译的 tfs2.2.16

    [root@2f60c4bcddfa tfs_release-2.2.16]# find -name Makefile | xargs sed -i 's/-Werror//' 问题 : In file included from session_util.cpp:1:0: session_util.h:30:43: 错误:‘int32_t’不是一个类型名 ...

    linux.chm文档

    hdparm -i /dev/hda 罗列一个磁盘的架构特性 hdparm -tT /dev/sda 在磁盘上执行测试性读取操作 cat /proc/cpuinfo 显示CPU info的信息 cat /proc/interrupts 显示中断 cat /proc/meminfo 校验内存使用 cat /...

Global site tag (gtag.js) - Google Analytics