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
。
分类:
linux shell
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!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中利用命令行发送邮件