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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:50:51+00:00 2026-06-15T16:50:51+00:00

I need to remove/filter a very large log file i managed to bring the

  • 0

I need to remove/filter a very large log file
i managed to bring the log-file into blocks of text starting with a line containing <-- or --> ending with a line containing Content-Length:
now if this block of text contains the word REGISTER it need to be deleted.

i found the flowing example:

 # sed script to delete a block if /regex/ matches inside it
 :t
 /start/,/end/ {    # For each line between these block markers..
    /end/!{         #   If we are not at the /end/ marker
       $!{          #     nor the last line of the file,
          N;        #     add the Next line to the pattern space
          bt
       }            #   and branch (loop back) to the :t label.
    }               # This line matches the /end/ marker.
    /regex/d;       # If /regex/ matches, delete the block.
 }                  # Otherwise, the block will be printed.
 #---end of script---

written by Russell Davies on this page

but i do not know how to transport this to a single line statement to use in a pipe
my goal is to pipe a tail -F of the log file to the final version so it get updates by the minute

  • 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-15T16:50:52+00:00Added an answer on June 15, 2026 at 4:50 pm

    Try this:

    awk '/<--|-->/{rec=""; f=1} f{rec = rec $0 ORS} /Content-Length:/{ if (f && (rec !~ "REGISTER")) printf "%s",rec; f=0}' file
    

    If it doesn’t do what you want, provide more info on what you want along with sample input and output.

    To break down the above, here’s each statement on separate lines with some comments:

    awk '
       /<--|-->/ {rec=""; f=1} # find the start of the record, reset the string to hold it and set a flag to indicate we've started processing a record
       f {rec = rec $0 ORS}    # append to the end of the string containing the current record
       /Content-Length:/{      # find the end of the record
          if (f && (rec !~ "REGISTER")) # print the record if it doesn't contain "REGISTER"
             printf "%s",rec
          f=0                  # clear the "found record" indicator
       }
    ' file
    

    and if you have text between your records that you’d want printed, just add a test for the “found” flag not being set and invoke the default action of printing the current record (!f;)

    awk '/<--|-->/{rec=""; f=1} f{rec = rec $0 ORS} !f; /Content-Length:/{ if (f && (rec !~ "REGISTER")) printf "%s",rec; f=0}' file
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to filter an array to remove the elements that are lower than
I need ideas with the best performance to remove/filter strings I have: string Input
I have a 2D vector and I need to remove blocks that do not
I need to remove the border-top: 1px solid #202020; from .contact on my contact
I need to remove all classes of 'no-right-marg' on all #tips li elements. I
I need to remove break from a specific div , i know how to
I need to remove element from com.google.gwt.core.client.JsArray . Also I need to empty the
I need to remove the following format from the end of a string in
I need to remove whitespaces after the word in the string. Can this be
I need to remove all entries in a dictionary accordingly to a specified lower

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.