[ILUGC] Re: How to insert a new line above 2 lines (above the pattern match)

  • From: Gopinath M <mgopi1990@xxxxxxxxx>
  • To: ilugc@xxxxxxxxxxxxx
  • Date: Sat, 5 Sep 2020 13:57:15 +0530

sed 's|^[0-9][0-9]*$|\n\n&|' file > a.out
On Sat, Sep 5, 2020, 1:55 PM Gopinath M <mgopi1990@xxxxxxxxx> wrote:

hope this helps...

sed 's|[0-9][0-9]*|\n\n&|' file > a.out

On Fri, Sep 4, 2020, 6:32 PM Baskar Selvaraj <baskar@xxxxxxxxxxxx> wrote:

Hi all,
I have been searching for a solution for inserting a new line above the
pattern match (2 lines above the pattern)

All search leads to, how to insert a line before the pattern only.

search pattern: -->

Before:

4
00:00:45.570 --> 00:00:47.940
of aerospace propulsion.
5
00:00:47.940 --> 00:00:54.940
The course will be taken by two of us.


After:

4
00:00:45.570 --> 00:00:47.940
of aerospace propulsion.

5
00:00:47.940 --> 00:00:54.940
The course will be taken by two of us.

S. Baskar


---
Mailing List Guidelines: https://ilugc.in/mailing-list-guidelines
Web: http://ilugc.in/
Internet Relay Chat: #ilugc on irc.freenode.net




---
Mailing List Guidelines: https://ilugc.in/mailing-list-guidelines
Web: http://ilugc.in/
Internet Relay Chat: #ilugc on irc.freenode.net

Other related posts: