Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3303364
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:56:58+00:00 2026-05-17T20:56:58+00:00

The syntax for this is: sed -n ‘/Regex1/,/Regex2/p’ But this includes the lines where

  • 0

The syntax for this is:

sed -n '/Regex1/,/Regex2/p'

But this includes the lines where Regex1 and Regex2 are found, how can I exclude them?

For example:

abcd-Regex1

BlaBlaBla

abcd-Regex2

Then I only want: BlaBlaBla

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:56:58+00:00Added an answer on May 17, 2026 at 8:56 pm

    You can do this with a simple state machine in awk:

    pax> echo 'abcd-Regex1
    BlaBlaBla
    abcd-Regex2' | awk '/Regex2/{e=0}{if(e){print}}/Regex1/{e=1}'
    
    BlaBlaBla
    

    It basically uses an echo flag e, with the commands below executed in sequence for each line:

    • /Regex2/{e=0} turns echo off when terminating line found.
    • {if(e){print}} prints line if echo is on.
    • /Regex1/{e=1} turns echo on when initialising line found.

    If you must use only sed, there is a way you can do it by passing it through another sed to delete the start and end lines:

    pax> echo 'asdf
    abcd-Regex1
    BlaBlaBla
    abcd-Regex2' | sed -n '/Regex1/,/Regex2/p' | sed -e '/Regex1/d' -e '/Regex2/d'
    
    BlaBlaBla
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I've seen this syntax before, but I can't remember it/find it on
Using this syntax I can add records in the fields but it always add
Can someone explain to me what syntax this SQL query matches? SELECT DISTINCT boats.boatid
I must have a syntax problem, but I cannot understand what this means -
This syntax works in FF <input data-bind=checked: isRequest, attr: { name: 'id_' + id
I find this syntax astoundingly annoying. Every time I rename my class, I have
I've seen this syntax show up, and have tried to google for it's definition
What does a syntax like this mean in C#? public abstract class HostFactory<TApp> :
According to Wikipedia this syntax looks correct... INSERT INTO dbo.metadata_type (name, publishable) VALUES (Content
Why doesn't php support this syntax: $s = explode('-', 'foo-bar')[0]; ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.