开发者

GREP - "dot match newline" option?

开发者 https://www.devze.com 2023-04-04 14:14 出处:网络
Example: ... Line some text other text 10 ... Is it possible to tell GREP ^Line.*?^10$ so that dot matches also newline and I get this output:

Example:

...
Line
some text
other text
10
...

Is it possible to tell GREP ^Line.*?^10$ so that dot matches also newline and I get this output:

Line
some text
other text
10

If not, is ther开发者_StackOverflow社区e some Linux CLI tool that can do it?


If your intend is to output lines between, and including, Line and 10, I suggest to use awk:

awk '/^Line$/,/^10$/' myfile


Use sed:

sed -rn '/^Line$/,/^10$/p' filename
0

精彩评论

暂无评论...
验证码 换一张
取 消