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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:34:04+00:00 2026-05-27T05:34:04+00:00

My file is: DIVIDER Sometext_string many lines of random text DIVIDER Another_Sometext_string many many

  • 0

My file is:

DIVIDER  
Sometext_string

many  
lines  
of random  
text  
DIVIDER  
Another_Sometext_string  
many  
many  
lines  
DIVIDER  
Third_sometext_string  
....

How change lines following DIVIDER pattern

Result must be:

DIVIDER  
[begin]Sometext_string[end]

many 
lines  
of random  
text  
DIVIDER  
[begin]Another_Sometext_string[end]

many  
many  
lines  
DIVIDER  
[begin]Third_sometext_string[end]

....
  • 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-27T05:34:04+00:00Added an answer on May 27, 2026 at 5:34 am

    May be this would help –

    sed '/DIVIDER/{n;s/.*/[begin]&[end]\n/;}' file1
    

    Execution:

    [jaypal:~/Temp] cat file1
    DIVIDER
    Sometext_string
    
    many
    lines
    of random
    text
    DIVIDER
    Another_Sometext_string
    many
    many
    lines
    DIVIDER
    Third_sometext_string
    
    [jaypal:~/Temp] sed '/DIVIDER/{n;s/.*/[begin]&[end]\n/;}' file1
    DIVIDER
    [begin]Sometext_string[end]
    
    
    many
    lines
    of random
    text
    DIVIDER
    [begin]Another_Sometext_string[end]
    
    many
    many
    lines
    DIVIDER
    [begin]Third_sometext_string[end]
    

    UPDATE:

    This version will handle one blank line after the first DIVIDER.

    [jaypal:~/Temp] sed -e '0,/DIVIDER/{n;s/.*/[begin]&[end]/;}' -e '/DIVIDER/{n;s/.*/[begin]&[end]\n/;}' file1
    DIVIDER
    [begin]Sometext_string[end]
    
    many
    lines
    of random
    text
    DIVIDER
    [begin]Another_Sometext_string[end]
    
    many
    many
    lines
    DIVIDER
    [begin]Third_sometext_string[end]
    
    [jaypal:~/Temp] 
    

    UPDATE 2:

    There are no other questions right now so that I thought I’d offer an alternate awk solution if you’d like? 🙂

    awk '/DIVIDER/{print;getline;sub(/.*/,"[begin]&[end]");print;next}1' file1
    
    [jaypal:~/Temp] awk '/DIVIDER/{print;getline;sub(/.*/,"[begin]&[end]\n");print;next}1' file1
    DIVIDER
    [begin]Sometext_string[end]
    
    
    many
    lines
    of random
    text
    DIVIDER
    [begin]Another_Sometext_string[end]
    
    many
    many
    lines
    DIVIDER
    [begin]Third_sometext_string[end]
    
    [jaypal:~/Temp] 
    

    This to handle first blank line after DIVIDER –

    [jaypal:~/Temp] awk '/DIVIDER/{count++;print;getline;if(count==1) sub(/.*/,"[begin]&[end]");else sub(/.*/,"[begin]&[end]\n");print;next}1' file1
    DIVIDER
    [begin]Sometext_string[end]
    
    many
    lines
    of random
    text
    DIVIDER
    [begin]Another_Sometext_string[end]
    
    many
    many
    lines
    DIVIDER
    [begin]Third_sometext_string[end]
    
    [jaypal:~/Temp] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

FILE *out=fopen64(text.txt,w+); unsigned int write; char *outbuf=new char[write]; //fill outbuf printf(%i\n,ftello64(out)); fwrite(outbuf,sizeof(char),write,out); printf(%i\n,write); printf(%i\n,ftello64(out));
I want to change the color of child divider of ExpandableListView by writing: android:childDivider=@drawable/yellow
The file views.py of my Django application has over 4000 lines of code right
Suppose I have a text file that says: This file has plain text Now,
I have the following XML file getting populated via list view. I can't get
i have a javascript file about 6000+ lines of codes created by myself. Now
Let's say I have a tab-delimited text file that contains data arranged in columns
I have a text file that is encoded in UTF-8. I'm reading it in
I have 100Mb text file and I need to check every line for special
I have an ASCII text file. I want to read the file, line by

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.