001、rename
[root@PC1 test]# ls 1.csv 2.csv 3.csv a.txt b.txt c.txt [root@PC1 test]# rename ".txt" "" *.txt ## 删除.txt后缀 [root@PC1 test]# ls 1.csv 2.csv 3.csv a b c [root@PC1 test]# rename ".csv" "" *.csv ## 删除.csv后缀 [root@PC1 test]# ls 1 2 3 a b c
002、
[root@PC1 test]# ls 1.csv 2.csv 3.csv a.txt b.txt c.txt [root@PC1 test]# for i in $(find *); do mv $i ${i%.*}; done ## 利用循环实现 [root@PC1 test]# ls 1 2 3 a b c
003、
[root@PC1 test]# ls 1.csv 2.csv 3.csv a.txt b.txt c.txt ## 循环实现 [root@PC1 test]# for i in $(find *); do mv $i $(echo $i | sed 's/.csv$\|.txt$//'); done [root@PC1 test]# ls 1 2 3 a b c
004、
[root@PC1 test]# ls 1.csv 2.csv 3.csv a.txt b.txt c.txt ## 循环 [root@PC1 test]# for i in $(find *); do mv $i $(echo $i | sed 's/....$//'); done [root@PC1 test]# ls 1 2 3 a b c
005、
[root@PC1 test]# ls 1.csv 2.csv 3.csv a.txt b.txt c.txt ## 循环 [root@PC1 test]# for i in $(find *); do mv $i ${i//.*/}; done [root@PC1 test]# ls 1 2 3 a b c
参考:https://www.cnblogs.com/xiami-xm/p/11253215.html
标签:csv,批量,后缀,PC1,ls,linux,test,txt,root From: https://www.cnblogs.com/liujiaxin2018/p/17398251.html