Match with sed between 2 different patterns [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
Print lines between (and excluding) two patterns
3 answers
I want to catch the output between 2 different patterns, for example :
sed -n '/^pattern1/,/^pattern2/p;/^pattern2/q'
But I want to catch the output without the patterns in cause.
I know that grep -Ev
will help me, but I wonder how it's done with sed.
linux sed
marked as duplicate by don_crissti, Jeff Schaller, Kiwy, Philippos, Timothy Martin Apr 10 at 17:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
Print lines between (and excluding) two patterns
3 answers
I want to catch the output between 2 different patterns, for example :
sed -n '/^pattern1/,/^pattern2/p;/^pattern2/q'
But I want to catch the output without the patterns in cause.
I know that grep -Ev
will help me, but I wonder how it's done with sed.
linux sed
marked as duplicate by don_crissti, Jeff Schaller, Kiwy, Philippos, Timothy Martin Apr 10 at 17:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I don't quite understand the "without the patterns in cause" bit.
â Kusalananda
Apr 10 at 9:34
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Print lines between (and excluding) two patterns
3 answers
I want to catch the output between 2 different patterns, for example :
sed -n '/^pattern1/,/^pattern2/p;/^pattern2/q'
But I want to catch the output without the patterns in cause.
I know that grep -Ev
will help me, but I wonder how it's done with sed.
linux sed
This question already has an answer here:
Print lines between (and excluding) two patterns
3 answers
I want to catch the output between 2 different patterns, for example :
sed -n '/^pattern1/,/^pattern2/p;/^pattern2/q'
But I want to catch the output without the patterns in cause.
I know that grep -Ev
will help me, but I wonder how it's done with sed.
This question already has an answer here:
Print lines between (and excluding) two patterns
3 answers
linux sed
edited Apr 10 at 9:48
Jeff Schaller
31.1k846105
31.1k846105
asked Apr 10 at 9:32
Andrei N
1
1
marked as duplicate by don_crissti, Jeff Schaller, Kiwy, Philippos, Timothy Martin Apr 10 at 17:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by don_crissti, Jeff Schaller, Kiwy, Philippos, Timothy Martin Apr 10 at 17:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I don't quite understand the "without the patterns in cause" bit.
â Kusalananda
Apr 10 at 9:34
add a comment |Â
I don't quite understand the "without the patterns in cause" bit.
â Kusalananda
Apr 10 at 9:34
I don't quite understand the "without the patterns in cause" bit.
â Kusalananda
Apr 10 at 9:34
I don't quite understand the "without the patterns in cause" bit.
â Kusalananda
Apr 10 at 9:34
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
You can try using awk
:
awk '/^pattern1/p=1;next/^pattern2/p=0p' file
The variable p
is set when the pattern pattern1
is found, and the variable is reset when the second pattern is met.
The p
at the end of the script will trigger the default awk action, i.e. print the line if p==1
.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can try using awk
:
awk '/^pattern1/p=1;next/^pattern2/p=0p' file
The variable p
is set when the pattern pattern1
is found, and the variable is reset when the second pattern is met.
The p
at the end of the script will trigger the default awk action, i.e. print the line if p==1
.
add a comment |Â
up vote
0
down vote
You can try using awk
:
awk '/^pattern1/p=1;next/^pattern2/p=0p' file
The variable p
is set when the pattern pattern1
is found, and the variable is reset when the second pattern is met.
The p
at the end of the script will trigger the default awk action, i.e. print the line if p==1
.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You can try using awk
:
awk '/^pattern1/p=1;next/^pattern2/p=0p' file
The variable p
is set when the pattern pattern1
is found, and the variable is reset when the second pattern is met.
The p
at the end of the script will trigger the default awk action, i.e. print the line if p==1
.
You can try using awk
:
awk '/^pattern1/p=1;next/^pattern2/p=0p' file
The variable p
is set when the pattern pattern1
is found, and the variable is reset when the second pattern is met.
The p
at the end of the script will trigger the default awk action, i.e. print the line if p==1
.
answered Apr 10 at 9:46
oliv
92427
92427
add a comment |Â
add a comment |Â
I don't quite understand the "without the patterns in cause" bit.
â Kusalananda
Apr 10 at 9:34