shell script to replace a string in a file

1. In the file containing the jack string in the current directory, replace the jack string with tom
sed -i "s/jack/tom/g" `grep "jack" -rl ./`

2. Replace the jack in a file String replacement with tom

sed -i "s/jack/tom/g" test.txt

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326394505&siteId=291194637