假设,我们得到以下包含字符串的变量:
text="All of this is one line. But it consists of multiple sentences. Those are separated by dots. I'd like to get this sentence."
我现在需要最后一句“我想得到这句话。”。我尝试使用 sed:
echo "$text" | sed 's/.*\.*\.//'
我认为它会删除所有的模式.*.
。它没有。
这里有什么问题?我确信这可以很快解决,不幸的是我没有找到任何解决方案。