我在Mac上,我希望找到与string_to_replace
匹配的所有字符串,并将其替换为new_string
答案 0 :(得分:1)
使用find和exec
[mymac]$ find . -name model.txt -exec sed -i .bak 's/string_to_replace/new_string/g' {} +
在mac(或者可能是所有基于BSD的系统)上,必须使用备份文件。如果您不需要备份文件,请将其删除
[mymac]$ find . -name model.txt.bak -exec rm {} +