效率提高练习

批量重命名文件

注: rename 只能用于文件不可用于目录方法一: rename

rename

方法二: for

for var in *.xml.example; do mv "$var" "${var%.xml.example}.xml"; done 

for

批量重命名目录

[root@slave2 test]# ls
file.sh         room_4_12_18_1  room_4_15_18_1  room_4_2_18_1   room_4_24_18_1  room_4_31_18_1  room_4_33_18_1  room_4_36_18_1  room_4_42_18_1  room_4_45_18_1  room_4_5_18_1   room_4_54_18_1  room_4_6_18_1
room_4_11_18_1  room_4_13_18_1  room_4_16_18_1  room_4_22_18_1  room_4_25_18_1  room_4_3_18_1   room_4_34_18_1  room_4_41_18_1  room_4_43_18_1  room_4_46_18_1  room_4_52_18_1  room_4_55_18_1
room_4_1_18_1   room_4_14_18_1  room_4_21_18_1  room_4_23_18_1  room_4_26_18_1  room_4_32_18_1  room_4_35_18_1  room_4_4_18_1   room_4_44_18_1  room_4_51_18_1  room_4_53_18_1  room_4_56_18_1
[root@slave2 test]# for i in `ls |grep room`;do  mv -f $i  `sed -e 's/room_//' -e 's/_/./g'  <<< $i` ;done 
[root@slave2 test]# ls
4.11.18.1  4.12.18.1  4.14.18.1  4.16.18.1  4.2.18.1   4.23.18.1  4.25.18.1  4.31.18.1  4.32.18.1  4.34.18.1  4.36.18.1  4.4.18.1   4.43.18.1  4.45.18.1  4.51.18.1  4.52.18.1  4.54.18.1  4.56.18.1  file.sh
4.1.18.1   4.13.18.1  4.15.18.1  4.21.18.1  4.22.18.1  4.24.18.1  4.26.18.1  4.3.18.1   4.33.18.1  4.35.18.1  4.41.18.1  4.42.18.1  4.44.18.1  4.46.18.1  4.5.18.1   4.53.18.1  4.55.18.1  4.6.18.1
[root@slave2 test]# 

检索目录匹配

3.1.18.1	 3.2.18.2	 3.1.18.2	3.2.18.1	3.3.18.2	3.12.18.1 	 3.12.18.2	 3.13.18.1	 ....

3.[1-3]\?2.18.[1-2] 

查看当前所有游戏组件版本

[root@localhost test]# for i in `ls |egrep -v 'conf|proxy|dbproxy|all_game|monitor'`;do ./$i/bin/$i -v ;done   
AiFrame Build1.0.2.12_12560_20180810  
challenge Build1.0.0.3_9720_20180322 
gate Build1.0.1.15_12908_20180904 
list Build1.0.0.21_12902_20180904 
lobby Build1.0.3.95_13045_20180914 
lock Build1.0.0.1_10980_20180514 
match_room Build1.0.0.20_12983_20180907 
rank Build1.1.0.7_12359_20180802 
room Build1.1.1.51_12984_20180907 status Build1.0.0.3_11806_20180625   
[root@localhost test]#  
comments powered by Disqus