この質問にはすでに回答があります :ディレクトリ内のファイルの名前を変更する
(6つの回答)
ファイル拡張子をクリーンアップする方法
(7つの回答)
7年前に閉鎖されました。
Linux
(6つの回答)
ファイル拡張子をクリーンアップする方法
(7つの回答)
7年前に閉鎖されました。
以下のファイルリストがあります
aro_tty-mIF-45875564pmo_opt
aro_tty-mIF-45875664pmo_opt
aro_tty-mIF-45875964pmo_opt
aro_tty-mIF-45875514pmo_opt
aro_tty-mIF-45875524pmo_opt
名前を変更する必要があります
aro_tty-mImpFRA-45875564pmo_opt
aro_tty-mImpFRA-45875664pmo_opt
aro_tty-mImpFRA-45875964pmo_opt
aro_tty-mImpFRA-45875514pmo_opt
aro_tty-mImpFRA-45875524pmo_opt
承認された回答:
ほとんどの標準シェルは、シェル変数内で単純なテキスト置換を行う方法を提供します。 http://tldp.org/LDP/abs/html/parameter-substitution.htmlは次のように説明しています。
${var/Pattern/Replacement}
First match of Pattern, within var replaced with Replacement.
したがって、このスクリプトを使用して、適切なすべてのファイルをループし、それぞれの名前を変更します。
for file in aro_tty-mIF-*_opt
do
mv -i "${file}" "${file/-mIF-/-mImpFRA-}"
done
各名前変更操作を確認できるように、-iオプションを追加しました。いつものように、大量の名前変更や削除を行う前に、すべてのファイルのバックアップを作成する必要があります。