Shell 全局替换

来源:互联网 发布:淘宝库房分拣员累吗 编辑:程序博客网 时间:2024/06/14 01:55


1. 全局替换Debug 未Debugger.

$ grep -r "Debug.Log" * | awk -F : '{print $1}' | sort | uniq | grep ".cs$" | xargs sed -i 's/Debug.Log/Debugger.Log/g'

解释:

grep -r,递归目录的意思。

awk -F : , 是以 :为分界符。


2. 全局替换textureFormat: . 为textureFormat: -3

$ find . -name "*.png.meta" | xargs sed -i '/textureFormat/s/textureFormat: .*/textureFormat: -3/'


Mac:

find . -name "*.png.meta" | grep -v ' ' | xargs sed -i ""  '/textureFormat/s/textureFormat: .*/textureFormat: -3/'
0 0