2

一个 bash 脚本请求(或 fish 脚本)。我有一堆文件,例如:

SDF1211B-03 - name - lastname.info
SDF1213B-04 - names  - lastnames.info
SDF1211B-05 - name & name - lastname & lastname.info

但我想将它们全部更改为:

name - lastname.info
names  - lastnames.info
name & name - lastname & lastname.info
4

2 回答 2

10

我会用 for 循环和${X#Y}shell 模式来做到这一点:

for f in SDF?????-??' - '* ; do
    mv "$f" "${f#SDF?????-?? - }"
done
于 2013-05-24T15:19:38.460 回答
0

你可以这样做:

for x in SDF*.info; do
    mv "$x" "$(echo $x | cut -c14-)"
done
于 2013-05-24T15:22:46.853 回答