grep -rn可以关键词查找符合条件的文件的行;去重文件名,然后xargs替换模式 grep -rn "xxx" . |cut -d ':' -f 1 |sort |uniq |xargs sed -i 's/xxx /yyy/g'