Linux 中 xargs 选项中-I将左侧变量传入{}

 

001、

a、总变量传入

复制代码
[root@PC1 test1]# ls            ## 测试文件及目录
a.txt  b.txt  c.csv  test
[root@PC1 test1]# tree          ## 查看目录结构
.
├── a.txt
├── b.txt
├── c.csv
└── test

1 directory, 3 files
[root@PC1 test1]# find *.txt
a.txt
b.txt
[root@PC1 test1]# find *.txt | xargs -I {} mv {} test     ## xargs 中 -I选项实现将左侧变量传入 {}; 然后结合mv移动至test目录
[root@PC1 test1]# ls
c.csv  test
[root@PC1 test1]# tree
.
├── c.csv
└── test
    ├── a.txt
    └── b.txt

1 directory, 3 files
复制代码

 

b、单个变量传入

复制代码
[root@PC1 test1]# ls            ## 测试文件及目录
a.txt  b.txt  c.csv  test
[root@PC1 test1]# tree
.
├── a.txt
├── b.txt
├── c.csv
└── test

1 directory, 3 files
[root@PC1 test1]# find *.txt
a.txt
b.txt
[root@PC1 test1]# find *.txt | xargs -n 1 -I {} mv {} test/        ## -I选项将单个变量传入{}
[root@PC1 test1]# ls
c.csv  test
[root@PC1 test1]# tree
.
├── c.csv
└── test
    ├── a.txt
    └── b.txt

1 directory, 3 files
复制代码

 。

 

posted @   小鲨鱼2018  阅读(101)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2023-02-09 linux 中设置root用户无法删除的文件
2023-02-09 linux 中设置root用户无法删除的文件
2023-02-09 linux 中如何给普通用户增加管理员权限
2023-02-09 linux 中同时输出一组数值的最大值和最小值
2023-02-09 linux centos中利用命令行发送邮件
点击右上角即可分享
微信分享提示