重命名我有一個命名爲批量使用shell腳本
input (1).txt
input (2).txt
input (3).txt
...
input (207).txt
如何重新命名這些文件
input_1.in
input_2.in
input_3.in
...
input_207.in
我想這
for f in *.txt ; do mv $f `echo $f | sed -e 's/input\ (\(\d*\))\.txt/input_\1.in/'` ; done
但是它給出了一個文件夾我
mv: target `(100).txt' is not a directory
mv: target `(101).txt' is not a directory
mv: target `(102).txt' is not a directory
...
我哪裏出錯了?
我已經把報價了,但我得到這個現在
mv: `input (90).txt' and `input (90).txt' are the same file
它是某種試圖文件重命名爲相同的名稱。這是怎麼發生的?
這個'mv:'input(90).txt'和'input(90).txt'是同一個文件' – Lazer 2010-08-22 07:07:08
我不認爲你可以使用'\ d'(從我記得的),嘗試使用'[0-9]'。 – NawaMan 2010-08-22 07:21:00
謝謝! '[0-9]'工作。爲什麼'\ d'不工作? – Lazer 2010-08-22 07:36:16