use*_*900 1 unix bash escaping sed character
我需要从 bash 中的字符串中删除转义字符。我得到一个数据结构,其中包含带有 / 转义的 url 路径,因此我收到了常规链接:
http://stackoverflow.com/questions/ask
Run Code Online (Sandbox Code Playgroud)
作为转义 / 之一:
http:\/\/stackoverflow.com\/questions\/ask
Run Code Online (Sandbox Code Playgroud)
现在我需要从第二个链接中删除 \。为此,我尝试使用 sed
`echo '"'${paths[$index]}'"' | sed "s@\\@@g"`
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误:
sed: -e expression #1, char 6: unterminated `s' command
Run Code Online (Sandbox Code Playgroud)
如果我用 ie 替换 \\ 。_ 它就像一个魅力,并删除字符串中所有出现的 _。如何使用 sed 去除字符串中的转义字符?
尝试这个:
.......|sed 's@\\@@g'
Run Code Online (Sandbox Code Playgroud)
或者:
.......|sed "s@\\\\@@g"
Run Code Online (Sandbox Code Playgroud)
编辑添加一个测试输出:
kent$ echo "http:\/\/stackoverflow.com\/questions\/ask"|sed "s@\\\\@@g"
http://stackoverflow.com/questions/ask
kent$ echo "http:\/\/stackoverflow.com\/questions\/ask"|sed 's@\\@@g'
http://stackoverflow.com/questions/ask
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9108 次 |
| 最近记录: |