NewIPIsComing
2020-12-10 09:38:22 +08:00
雖然我已經知道樓主並不是要找命令行程序,但我還是忍不住推薦一條現成的命令:
#替換文件夾中所有文件中的 old_string 為 new_string
grep -rl "old_string" . | xargs sed -i 's/old_string/new_string/g'
# grep -rl: search recursively, and only print the files that contain “old_string”
# xargs: take the output of the grep command and make it the input of the next command (ie, the sed command)
# sed -i ‘s/old_string/new_string/g’: search and replace, within each file, old_string by new_string