![如何使用 sed [重复] 将字符串替换为包含特殊字符的字符串](https://linux22.com/image/187105/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20sed%20%5B%E9%87%8D%E5%A4%8D%5D%20%E5%B0%86%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%9B%BF%E6%8D%A2%E4%B8%BA%E5%8C%85%E5%90%AB%E7%89%B9%E6%AE%8A%E5%AD%97%E7%AC%A6%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2.png)
例如
代替
keystore=".
和
keystore="./
答案1
您需要转义特殊字符。我假设该字符串位于文件中yourfile
sed -i 's@keystore="\.@keystore="\./@' yourfile
有关 sed 特殊字符的更多详细信息可以在这里找到在 sh 脚本中使用 sed 时需要转义哪些字符?
例如
代替
keystore=".
和
keystore="./
您需要转义特殊字符。我假设该字符串位于文件中yourfile
sed -i 's@keystore="\.@keystore="\./@' yourfile
有关 sed 特殊字符的更多详细信息可以在这里找到在 sh 脚本中使用 sed 时需要转义哪些字符?