我想在一个句号结尾的行下面添加一条黑线。
我有sed '/ REGEX goes here/G'
我不知道如何将正则表达式替换为除了作为要查找的表达式的句点。
我想在每个句子下面添加一个空行,这里是我想要使用sed shell脚本的一些文本示例。
Line one.
The second line.
The third.
This is line four.
five.
This is the sixth sentence.
This is line seven.
Eighth and last.
答案 0 :(得分:1)
尝试关注sed
sed 's/\.$/.\n/' file
编辑(在 @Jotne 的评论之后)
如果您在行尾.
之后有空格,则添加\s*
将是安全的。
sed 's/\.\s*$/.\n/' file
答案 1 :(得分:0)
我不知道如何将正则表达式替换为句点之外的句号 寻找。
你可以说:
sed '/\.$/G' filename
退出.
以匹配文字.
;锚$
确保匹配的.
位于行尾。