愿意只保留最后一个包含点的单词 block (仍然保留不包含模式的单词):
sed 似乎只匹配最后一个单词:
$ echo "Here this.is.a.start is a very.nice.String that.is.the.end yes " | sed 's/.*[ ]\([^ ]*\.\)\([^ ]*\)[ ].*/\2/g'
end
$ echo "Here this.is.a.start is a very.nice.String that.is.the.end yes " | sed 's/.*[ ]\([^ ]*\.\)\([^ ]*\)[ ].*/\1/g'
that.is.the.
我应该怎样做才能得到这个结果? :
echo "Here this.is.a.start is a very.nice.String that.is.the.end yes " | sed s\\\g
Here start is a String end yes
最佳答案
用\w 表示一个单词:
echo "Here this.is.a.start is a very.nice.String that.is.the.end yes " |
sed -E 's/\w*\.//g'
关于shell - sed:保留包含 block 模式的每个单词的最后一个 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64281386/