regex - 如何使用 sed 命令替换 "$"?

标签 regex linux sed

假设我有一些文字 A B $ D E在一个文件中,我想用 y 替换 $。我们怎样才能?

我试过sed 's/$/y' filename > filename1 ,但没有成功。

最佳答案

它不起作用,因为 $special character in regular expressions .

尝试使用 sed 's/\$/y/' filename > filename1 代替。

关于regex - 如何使用 sed 命令替换 "$"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27432038/

相关文章:

bash - 使用 shell 变量调用 sed

python - 根据定界符吐出一列

regex - 我如何使用正则表达式 "inverse match"?

regex - perl 中的正则表达式和重复字符类

c - 如何获取动态分配的内存大小?

c - 是否可以在 GTK 中的另一个应用程序中运行一个应用程序?

正则表达式替换转义字符

linux - Bash 调试调用堆栈

bash - 在 bash 脚本中转义 sed 字符串

linux - 查找并替换文档中的文本