Twitterでそんな感じの処理について見かけたので、あとで引っ張ってこれるように残しておく。 といっても大したことはせず、普通にfindコマンドでexecするときにrenameすればいいだけだ。 このとき、ファイル名にシングルクォートがあったとしてもリネームができるよう、findで得たファイル名をダブルクォーテーションで囲ってやればいい。

find ./ 条件 -exec rename 置換前文字列 置換後文字列 "{}" \;

[root@BS-PUB-CENT7-01 test2]# ls -la
合計 8
drwxr-xr-x. 2 root root 4096  4月  5 08:05 .
dr-xr-x---. 8 root root 4096  4月  5 07:16 ..
-rw-r--r--. 1 root root    0  4月  3 08:27 def_00's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_01's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_02's.txt
-rw-r--r--. 1 test test    0  4月  3 08:27 def_03's.txt.bk2
-rw-r--r--. 1 test test    0  4月  3 08:27 def_04's.txt.bk2
-rw-r--r--. 1 test test    0  4月  3 08:27 def_05's.txt.bk2
-rw-r--r--. 1 root root    0  4月  3 08:27 def_06's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_07's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_08's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_09's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_10's.txt
[root@BS-PUB-CENT7-01 test2]# find ./ -user test -exec rename def ABC "{}" \;
[root@BS-PUB-CENT7-01 test2]# ls -la
合計 8
drwxr-xr-x. 2 root root 4096  4月  5 08:05 .
dr-xr-x---. 8 root root 4096  4月  5 07:16 ..
-rw-r--r--. 1 test test    0  4月  3 08:27 ABC_03's.txt.bk2
-rw-r--r--. 1 test test    0  4月  3 08:27 ABC_04's.txt.bk2
-rw-r--r--. 1 test test    0  4月  3 08:27 ABC_05's.txt.bk2
-rw-r--r--. 1 root root    0  4月  3 08:27 def_00's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_01's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_02's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_06's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_07's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_08's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_09's.txt
-rw-r--r--. 1 root root    0  4月  3 08:27 def_10's.txt