經常在部署tomcat時需要替換配置文件中的ip,find命令批量替換還是很方便的
查找需要替換的ip,看看哪些文件有配置這個ip,執行下面命令:
find ./ -type f -regex ".*\.xml\|.*\.js.*\|.*\.properties" | xargs grep "118.190.73.218"
查找完成后進行替換為139.129.208.20,執行下面命令:
find ./ -type f -regex ".*\.xml\|.*\.js.*\|.*\.properties" | xargs perl -pi -e"s/118.190.73.218/139.129.208.20/g"