Skip to main content
formatting; tags
Source Link
chaos
  • 49.4k
  • 11
  • 128
  • 147

Let's say I have a text file like this:

group1 hello group1 there group1 nice line group2 here group2 we group2 go 

What I want to do is insert a line when the group of lines changes, something like:

group1 hello group1 there group1 nice line --------------------------------------- group2 here group2 we group2 go 

I don't care if that line also appears as the first and/or last line. At this time I only need something that separates the information.

How do I do that with sed/ or awk? Or maybe there are other ways?

Let's say I have a text file like this:

group1 hello group1 there group1 nice line group2 here group2 we group2 go 

What I want to do is insert a line when the group of lines changes, something like:

group1 hello group1 there group1 nice line --------------------------------------- group2 here group2 we group2 go 

I don't care if that line also appears as the first and/or last line. At this time I only need something that separates the information.

How do I do that with sed/awk? Or maybe there are other ways?

Let's say I have a text file like this:

group1 hello group1 there group1 nice line group2 here group2 we group2 go 

What I want to do is insert a line when the group of lines changes, something like:

group1 hello group1 there group1 nice line --------------------------------------- group2 here group2 we group2 go 

I don't care if that line also appears as the first and/or last line. At this time I only need something that separates the information.

How do I do that with sed or awk? Or maybe there are other ways?

Source Link
sjngm
  • 547
  • 1
  • 6
  • 15

Insert Line in File When Group of Lines Changes

Let's say I have a text file like this:

group1 hello group1 there group1 nice line group2 here group2 we group2 go 

What I want to do is insert a line when the group of lines changes, something like:

group1 hello group1 there group1 nice line --------------------------------------- group2 here group2 we group2 go 

I don't care if that line also appears as the first and/or last line. At this time I only need something that separates the information.

How do I do that with sed/awk? Or maybe there are other ways?