zoukankan      html  css  js  c++  java
  • xargs命令学习

    1.xargs复制文件

    目录下文件结构为:

    .
    
    ├── demo1
    
    │   ├── test.lua
    
    │   ├── test.php
    
    │   └── test.txt
    
    └── demo2
    

      

    执行命令:

    find ./demo1/ -name  'test*'|cp `xargs` ./demo2/
    

      

    目录结构为:

    .
    
    ├── demo1
    
    │   ├── test.lua
    
    │   ├── test.php
    
    │   └── test.txt
    
    └── demo2
    
        ├── test.lua
    
        ├── test.php
    
        └── test.txt
    
     
    

      

    2.xargs复制文件

    [root@lx xargsTest]# tree
    
    .
    
    ├── demo1
    
    │   ├── test.lua
    
    │   ├── test.php
    
    │   └── test.txt
    
    └── demo2
    
        ├── test.lua
    
        ├── test.php
    
        └── test.txt
    
    find ./demo1/ -name  'test*'|xargs -i cp {} {}.bak
    
    .
    
    ├── demo1
    
    │   ├── test.lua
    
    │   ├── test.lua.bak
    
    │   ├── test.php
    
    │   ├── test.php.bak
    
    │   ├── test.txt
    
    │   └── test.txt.bak
    
    └── demo2
    
        ├── test.lua
    
        ├── test.php
    
        └── test.txt
    

      

    3.xargs删除文件

    查询以.bak结尾的文件

     find ./demo1/ -name  '*.bak'
    

      

    ./demo1/test.txt.bak
    
    ./demo1/test.lua.bak
    
    ./demo1/test.php.bak
    

      

    删除这些文件

    find ./demo1/ -name  '*.bak'|xargs rm -fr
    

      

    [root@lx xargsTest]# tree
    
    .
    
    ├── demo1
    
    │   ├── test.lua
    
    │   ├── test.php
    
    │   └── test.txt
    
    └── demo2
    
        ├── test.lua
    
        ├── test.php
    
        └── test.txt
    

      

    删除成功

  • 相关阅读:
    http://localhost:8080/ 演出Oracle说明
    JS浏览器类型推断方法
    MVC设计模式JavaWeb实现
    《TCP/IP详细说明》读书笔记(17章)-TCP传输控制协定
    创建表单
    道路软件质量:SourceMonitor
    HDU
    HDU 3032 Nim or not Nim? (sg函数求解)
    OpenWRT推理client线上的数
    IIS的ISAPI接口简介
  • 原文地址:https://www.cnblogs.com/lisqiong/p/5732850.html
Copyright © 2011-2022 走看看