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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:22:22+00:00 2026-05-31T22:22:22+00:00

I have a log of following format << [ABC] some other data some other

  • 0

I have a log of following format

<<
[ABC] some other data
some other data
>>

<<
DEF some other data
some other data
>>

<<
[ABC] some other data
some other data
>>

I wanted to select all logs which are having ABC expected result is

<<
[ABC] some other data
some other data
>>

<<
[ABC] some other data
some other data
>>

What will the expression for sed command ?
For fetching contents b/w << >> expression will be

sed -e '/<</,/>>/!d' 

But how can I force it to have [ABC] in b/w

  • 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-31T22:22:24+00:00Added an answer on May 31, 2026 at 10:22 pm

    This works on my side:

    awk '$0~/ABC/{print "<<";print;getline;print;getline;print }' temp.txt
    

    tested as below:

    pearl.242> cat temp.txt
    << 
    [ABC] some other data 
    some other data 
    >>  
    << 
    DEF some other data 
    some other data 
    >>  
    
    nkeem
    
    << 
    [ABC] some other data 
    some other data 
    >> 
    pearl.243> awk '$0~/ABC/{print "<<";print;getline;print;getline;print }' temp.txt
    <<
    [ABC] some other data 
    some other data 
    >>  
    <<
    [ABC] some other data 
    some other data 
    >> 
    pearl.244> 
    

    If you donot want to hard code this statement print "<<";,then you can go for the below:

    pearl.249> awk '$0~/ABC/{print x;print;getline;print;getline;print}{x=$0}' temp.txt
    << 
    [ABC] some other data 
    some other data 
    >>  
    << 
    [ABC] some other data 
    some other data 
    >> 
    pearl.250> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a log table with the following format (and sample data): date |
Am having a log file in following format: 201208290101 201208290101 201208290101 201208290101 201208290101 201208291222
I have log files that contain SQL statements in the following format: exec sp_executeSQL
I have log file in following format 14:15 14:16 14:17 14:30 14:31 14:41 I
for some reason I see url of the following format in error_log (might have
I have a filename in the following format: xx_xx_xx_xx/Run02/isf2sync_output/xx_xx_xx_xx_xx_Run02_xxx3_20120301_144327/xx_xx_xx_xx_xx_Run02_xxx3_20120301_144395.x.x.x.log I want to extract the
All, I have XML in the following format: <linked-list> <Description> <desc></desc> <IP></IP> </Description> </linked-list>
I have an app which allows users to log in via Facebook, and all
I have a mysql log table of machine in the following format. --------------------------------------------------------------------------------------------------- |
In my log file I have the text in the following format: 18 Mar

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.