Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 sed 中传递一个包含特殊字符的字符串。
如何转义“$”字符?
echo "$azerty$" | sed 's///g'
$ echo "\$azerty$" | sed 's/\$/X/g' XazertyX
如果要禁用变量插值,请使用单引号:
$ echo '$azerty$' | sed 's/\$/X/g' XazertyX
这对我有用(使用 GNU sed)
% echo "\$azerty\$" | sed -r -e 's/\$//g' azerty