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 8288647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:19:14+00:00 2026-06-08T12:19:14+00:00

I have a text file like Hi how are you <blank> <blank> abcd <blank>

  • 0

I have a text file like

Hi
how are you
<blank>
<blank>
abcd
<blank>
defgh
opqr
<blank>

I want to print all lines that have the pattern like “some text”blankblank”some text”
like

how are you
<blank>
<blank>
abcd

I am thinking about using join and then search for the pattern. But I am not sure how to do it. (By blank I mean empty line)

  • 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-06-08T12:19:15+00:00Added an answer on June 8, 2026 at 12:19 pm
    • Blank line: /^(?:(?!\n)\s)*\n/m
    • Non-blank line: /^.*\S.*\n/m

    So you want to print all instances of:

     /
        ^
        (?:
           .*\S.*\n
           (?: (?:(?!\n)\s)*\n ){2}
        )+
        .*\S.*\n
     /mx
    

    As a lone liner:

     perl -0777ne'print /^(?:.*\S.*\n(?:(?:(?!\n)\s)*\n){2})+.*\S.*\n/mg' file
    

    If all your blank lines contain no whitespace, you can simplify some:

    • Blank line: /^\n/m
    • Non-blank line: /^.+\n/m

     perl -0777ne'print /^(?:.+\n\n\n)+.+\n/mg' file
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text file with some stuff that i would like to put into
I have a text file that has multiple blank lines and Im trying to
I have a text file that looks like this. A 102 B 456 C
I have a text file that looks like: text texttext texttext texttext texttext text
I have an XML file formatted like <paragraph> Some Free text goes here<LinkType1 href=link1
I have a text file that looks like: 6789 Here is a bunch of
I have a text file that looks like this: [22/Nov/2011 12:57:58] GET /media/js/jquery-1.4.3.min.js HTTP/1.1
I have a file that I need to reformat and remove extra blank lines.
I have a text file with a thousand lines of numbers like so: 402
I have a text file like this: A B C And each element has

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.