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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:40:26+00:00 2026-06-08T11:40:26+00:00

Given this input file: SectionMarker and some random text here this is the text

  • 0

Given this input file:

SectionMarker and some random text here
this is the text in section 1 
this is the text in section 1
this is the text in section 1
etc
SectionMarker and some random text here also
this is the text in section 2 
this is the text in section 2
this is the text in section 2
etc
SectionMarker and some random text too
this is the text in section 3 
this is the text in section 3
this is the text in section 3
etc

How do I split this file in pieces using awk or sed or whatever ?

This is what I tried, but didn’t work:

awk -vRS='\SectionMarker[:print:]\n' 'NR==1 {print}' ./data.log 
  • 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-08T11:40:29+00:00Added an answer on June 8, 2026 at 11:40 am

    this one-liner should do the job:

     awk '{x+=($0~/^SectionMarker/)?1:0}x<2' data.log
    

    test

    kent$  cat data.log
    SectionMarker and some random text here
    this is the text in section 1 
    this is the text in section 1
    this is the text in section 1
    etc
    SectionMarker and some random text here also
    this is the text in section 2 
    this is the text in section 2
    this is the text in section 2
    etc
    SectionMarker and some random text too
    this is the text in section 3 
    this is the text in section 3
    this is the text in section 3
    etc
    
    kent$  awk '{x+=($0~/^SectionMarker/)?1:0}x<2' data.log
    SectionMarker and some random text here
    this is the text in section 1 
    this is the text in section 1
    this is the text in section 1
    etc
    

    i don’t know how many sections in your real problem you want to grab. you could place exit; in that onliner to make awk not process the whole file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This program produces the output I expect when given an input file of text
Given this HTML: <form id=formx> <input type=text value= /> </form> And this JavaScript: $(function()
Given this simplified snippet : <html> <body> <div> <div style='text-align:center;'>asdfaskjdfakjsd</div> <div style='float:right'> <input type='submit'
Ive managed to parse the entire contents of a given input text file and
Given a large input file that looks like this: 02/26/2012 08:54:38 Error:java.sql.Exception 02/26/2012 08:54:48
Given an input file of text lines, I want duplicate lines to be identified
So given this input string: =?ISO-8859-1?Q?TEST=2C_This_Is_A_Test_of_Some_Encoding=AE?= And this function: private string DecodeSubject(string input) {
Given this HTML: <div id=foo> <input type=button class=foo abtn_1> <input type=button class=joe bbtn_2> <input
Given this HTML: <div id=foo> <input type=button class=foo abtn_1> <input type=button class=joe bbtn_2> <input
Given input file z b a f g a b ... I want to

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.