Chi*_*tan 0 sed text-processing
如何替换字符串I1Rov4Rvh/GtjpuuYttr==
用mytest
在一个文件中mtestsed.properties
使用sed
的命令?
我试过了:
sed -e -i 's/I1Rov4Rvh/GtjpuuYttr==/mytest/g' mtestsed.properties
Run Code Online (Sandbox Code Playgroud)
sed 分隔符可以是任何字符,正是在需要将字符串替换为 /
任何一个
转义/
符:
sed -i 's/I1Rov4Rvh\/GtjpuuYttr==/mytest/g'
Run Code Online (Sandbox Code Playgroud)使用另一个分隔符:
sed -i 's|I1Rov4Rvh/GtjpuuYttr==|mytest|g'
Run Code Online (Sandbox Code Playgroud)
sed -i 's:I1Rov4Rvh/GtjpuuYttr==:mytest:g'
Run Code Online (Sandbox Code Playgroud)问题在于/
您要替换的文本中的 。这是一个特殊字符sed
,因此您需要使用\
. 同样如评论中指出的那样:该命令也因-e
需要脚本的选项而失败。
这应该有效:
sed -i 's/I1Rov4Rvh\/GtjpuuYttr==/mytest/g' mtestsed.properties
Run Code Online (Sandbox Code Playgroud)