如何告诉 sed“点匹配新行" [英] how to tell sed "dot match new line"
本文介绍了如何告诉 sed“点匹配新行"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道如何告诉 sed 点匹配新行:
I can't figure how to tell sed dot match new line:
echo -e "one\ntwo\nthree" |sed 's/one.*two/one/m'
我希望得到:
一个
三个
相反,我得到了原创:
一个
二
三个
one
two
three
推荐答案
sed
是基于行的工具.我不认为这些是一种选择.
你可以使用h/H
(hold), g/G
(get).
sed
is line-based tool. I don't think these is an option.
You can use h/H
(hold), g/G
(get).
$ echo -e 'one\ntwo\nthree' | sed -n '1h;1!H;${g;s/one.*two/one/p}'
one
three
也许你应该试试 vim
:%s/one\_.*two/one/g
这篇关于如何告诉 sed“点匹配新行"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文