Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

How to get all the lines after a matching word till the next different matching word?

For example, my input looks like below.

1 2 3 5 6 

and I need to sed from 1 to 5 and in my output I need to include 1 but I do not want to include 5and the remaining lines.

If my file contains no 5, I need to do have the remaining lines till the end.

NOTE: I saw the referenced link that looks like a duplicate to my question, titled: Show only text between 2 matching patternShow only text between 2 matching pattern but it doesn't answer my question. The answers there didn't include a way to handle if the secondmatch isn't in the file.

How to get all the lines after a matching word till the next different matching word?

For example, my input looks like below.

1 2 3 5 6 

and I need to sed from 1 to 5 and in my output I need to include 1 but I do not want to include 5and the remaining lines.

If my file contains no 5, I need to do have the remaining lines till the end.

NOTE: I saw the referenced link that looks like a duplicate to my question, titled: Show only text between 2 matching pattern but it doesn't answer my question. The answers there didn't include a way to handle if the secondmatch isn't in the file.

How to get all the lines after a matching word till the next different matching word?

For example, my input looks like below.

1 2 3 5 6 

and I need to sed from 1 to 5 and in my output I need to include 1 but I do not want to include 5and the remaining lines.

If my file contains no 5, I need to do have the remaining lines till the end.

NOTE: I saw the referenced link that looks like a duplicate to my question, titled: Show only text between 2 matching pattern but it doesn't answer my question. The answers there didn't include a way to handle if the secondmatch isn't in the file.

added 191 characters in body
Source Link
slm
  • 380k
  • 127
  • 793
  • 897

How to get all the lines after a matching word till the next different matching word?

For example, my input looks like below.

1 2 3 5 6 

and I need to sed from 1 to 5 and in my output I need to include 1 but I do not want to include 5and the remaining lines.

If my file contains no 5, I need to do have the remaining lines till the end.

NOTE: I saw the referenced link that looks like a duplicate to my question, titled: linkShow only text between 2 matching pattern but it doesn't answer my question. The answers there didn't include a way to handle if the secondmatch isn't in the file.

How to get all the lines after a matching word till the next different matching word?

For example, my input looks like below.

1 2 3 5 6 

and I need to sed from 1 to 5 and in my output I need to include 1 but I do not want to include 5and the remaining lines.

If my file contains no 5, I need to do have the remaining lines till the end.

I saw the referenced link but it doesn't answer my question.

How to get all the lines after a matching word till the next different matching word?

For example, my input looks like below.

1 2 3 5 6 

and I need to sed from 1 to 5 and in my output I need to include 1 but I do not want to include 5and the remaining lines.

If my file contains no 5, I need to do have the remaining lines till the end.

NOTE: I saw the referenced link that looks like a duplicate to my question, titled: Show only text between 2 matching pattern but it doesn't answer my question. The answers there didn't include a way to handle if the secondmatch isn't in the file.

added 148 characters in body
Source Link
Ramesh
  • 40.6k
  • 45
  • 149
  • 222

howHow to get all the lines after a matching word till the next different matching word? For

For example, my input looks like below.

1 2 3 5 6 

and I need to sedsed from 1 51 to 5 and in my output I need to include 11 but I do not want to include 5 and bellow but if file contains no 5 it could sed till end of file5and the remaining lines.

that link doesnt answersIf my questionfile contains no 5, iI need to seddo have the remaining lines till specific matchthe end.

I saw the referenced link but if thre is no that match in file it should sed till end of filedoesn't answer my question.

how to get all lines after matching word till next different matching word? For example

1 2 3 5 6 

and I need to sed from 1 5 include 1 but not include 5 and bellow but if file contains no 5 it could sed till end of file

that link doesnt answers my question, i need to sed till specific match but if thre is no that match in file it should sed till end of file

How to get all the lines after a matching word till the next different matching word?

For example, my input looks like below.

1 2 3 5 6 

and I need to sed from 1 to 5 and in my output I need to include 1 but I do not want to include 5and the remaining lines.

If my file contains no 5, I need to do have the remaining lines till the end.

I saw the referenced link but it doesn't answer my question.

added 143 characters in body
Source Link
Loading
deleted 27 characters in body
Source Link
Braiam
  • 36.9k
  • 29
  • 114
  • 176
Loading
added 27 characters in body
Source Link
Loading
added 63 characters in body
Source Link
Loading
added 24 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
Source Link
Loading