1.linux下精确替换某个字符串
sed -i 's/\<old\>/new/g' filename.txt
2.举例:
2.1有个文件名为filename.txt,内容如下:
newdalsad
dsadsaold
old
dnw
new
2.2 将精确查找到的old替换为new
sed -i 's/\<old\>/new/g' filename.txt
那么替换后内容如下:
newdalsad
dsadsaold
new
dnw
new
1.linux下精确替换某个字符串
sed -i 's/\<old\>/new/g' filename.txt
2.举例:
2.1有个文件名为filename.txt,内容如下:
newdalsad
dsadsaold
old
dnw
new
2.2 将精确查找到的old替换为new
sed -i 's/\<old\>/new/g' filename.txt
那么替换后内容如下:
newdalsad
dsadsaold
new
dnw
new
转载于:https://www.cnblogs.com/dakewei/p/8134892.html