1. Mac 批量修改字符串

1.1. 列出所有.m文件

$ find ./ -name *.m

1.2. vi中批量替换

:g#sourceString#s##targetString#g

1.3. sed命令下批量替换文件内容

格式: sed "s/查找字段/替换字段/g"

$ sed -i "" "s/sourceString/targetString/g" test.m
  • -i: 直接修改原文

1.4. 批量替换

#bin/sh
target_files=`find ./ -name *.m`
for target_file in ${target_files}
do
    echo ${target_file}
    sed -i "" "s/sourceString/targetString/g" ${target_file}
done

results matching ""

    No results matching ""