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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:41:45+00:00 2026-05-28T20:41:45+00:00

myfile.log contains things like: —– 12:08:12 (123.123.123.123) ——————————– Some code here… This section has

  • 0

myfile.log contains things like:

----- 12:08:12 (123.123.123.123) --------------------------------
Some code here...
This section has no specified length...
-----------------------------------------------------------------


----- 12:10:15 (254.14.187.123) --------------------------------
Some code here...
This section has no specified length...
It could be 3 lines, or 4 lines, or 20 lines. 
-----------------------------------------------------------------

I want to use something like grep to pull out every block that contains the IP address 123.123.123.123. For example, the following would be returned:

----- 12:08:12 (123.123.123.123) --------------------------------
Some code here...
This section has no specified length...
-----------------------------------------------------------------

Edit:
Thanks for the answers so far, I forgot to mention that I need it to stream the output in the same way tail would.

  • 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-28T20:41:46+00:00Added an answer on May 28, 2026 at 8:41 pm

    I would use something similar to:

    sed -n '/^-----.*(123\.123\.123\.123) ---/,/^------/p' file.log
    

    It first matches a line, starting with 5 hyphens, then contains a number of arbitrary characters, then the IP address enclosed in parentheses, followed by some hyphens. Then it matches all lines until it encounters a line that starts with 5 hyphens. You could use /^-\{5,\}$/ to specify a line that contains hyphens only (at least 5).

    Regarding the edit on your question: with streaming I assume you mean tail -f? Simply pipe its output into sed:

    tail -f file.log | sed -n '/^-----.*(123\.123\.123\.123) ---/,/^------/p'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple code inserted in myfile.hpp file inside a project of mine:
I am using this code: File myDir = new File(getApplicationContext().getFilesDir().getAbsolutePath()); try { Log.i(CSV Testing
When using this code in python: f = open('ping.log', 'r+') f.write([+time.ctime()+]+Status) f.close() My file
I have created a file named MyFile.db using SQLite3 from my C#.net application. This
If I use an URL like http://mysite/myfolder/myfile.dll , I get a dialog Do you
I have a file as documentRoot/app/webroot/myFile.php I need to be able to access this
I have a file, myfile.py , which imports Class1 from file.py and file.py contains
I am getting The process cannot access the file MyFile.log because it is being
See the code below: How do I send a parameter BASE_NAME = myfile to
Hello here is the code: URL uri = new URL(photoUrl); URLConnection connection = uri.openConnection();

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.