shell 脚本替换文件中某个字符串

时间:2021-08-26 09:02:32

sed -i "s/jack/tom/g" `grep "jack" -rl ./ `

1、将当前目录下包含jack串的文件中,jack字符串替换为tom

sed -i "s/jack/tom/g" `grep "jack" -rl ./`


sed -i "s/jack/tom/g" `grep "jack" -rl ./`

 

2、

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

将某个文件中的jack字符串替换为tom

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


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