目前我有一个文件
包含文本
Your path: ../test/tester [hello] whatever
但我想把它改成:Your path: ../../tested/text [hello] whatever
我尝试过 sed 但我相信 ../是一个特殊字符,所以我不太确定如何解决这个问题。
这对我不起作用。
sed s/tester/..//g;s/tester/tested/text/
最佳答案
这能解决您的问题吗?
➜ scripts cat example
Your path: ../test/tester [hello] whatever
➜ scripts sed "s|../test/tester|../../tested/text|" example > example2
➜ scripts cat example2
Your path: ../../tested/text [hello] whatever
关于regex - 对特殊字符使用 sed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23500745/