我想使用Sed替换所有字符之后包括指定的字符串,如下所示:
关键字
#specific-keyword
输入
Some text amongst which lies a #specific-keyword and everything else that follows.
输出
Some text amongst which lies a
我想出了类似的东西:
"Some text amongst which lies a #specific-keyword and everything else that follows." | sed "s/#specific-keyword*/ /g"
但它只会删除特定的关键字,而不会删除之后的字词。
答案 0 :(得分:0)
我刚刚想出答案,我的正则表达式错了。我需要将.*
添加到特定关键字的末尾,如下所示:
sed 'Some text amongst which lies a #specific-keyword and everything else that follows./#specific-keyword.*/ /g'