Match with sed between 2 different patterns [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this 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














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.







share|improve this 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












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.







share|improve this question















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









share|improve this question













share|improve this question




share|improve this question








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
















  • 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










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.






share|improve this answer



























    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.






    share|improve this answer
























      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.






      share|improve this answer






















        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 10 at 9:46









        oliv

        92427




        92427












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay