linux 中xargs命令实现批量重命名

 

001、

[root@pc1 test]# ls
[root@pc1 test]# touch test{1..5}
[root@pc1 test]# ls
test1  test2  test3  test4  test5
[root@pc1 test]# ls test* | xargs mv {} {}.txt
mv: target ‘test5’ is not a directory
[root@pc1 test]# ls
test1  test2  test3  test4  test5
[root@pc1 test]# ls test* | xargs -i mv {} {}.txt     ## 需要添加-i参数
[root@pc1 test]# ls
test1.txt  test2.txt  test3.txt  test4.txt  test5.txt

 

posted @ 2023-01-05 17:45  小鲨鱼2018  阅读(342)  评论(0编辑  收藏  举报