*-dev.example.com.cfg の名前を *-prod.example.com.cfg に変更する必要があります
たとえば、ファイル名が db-dev.example.com.cfg の場合、名前を db-prod.example.com.cfg に変更する必要があります。
200以上のファイルがありますが、コマンドラインからそれを行う方法はありますか?
パラメータ置換を使用して、純粋な bash でこれを行うことができます。
for file in *-dev.example.com.cfg; do
mv "$file" "${file/%-dev.example.com.cfg/-prod.example.com.cfg}"
done
rename
これには正規表現は必要ないため、Linux を使用しているため、util-linux から使用できます。Debian および Ubuntu などの派生物では、コマンドはrename.ul
.
rename dev.example.com.cfg prod.example.com.cfg *.cfg
zshにはzmvがあり、定期的にそのようなことを行う場合に便利かもしれませんhttp://zshwiki.org/home/builtin/functions/zmv