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

  • Home
  • SEARCH
  • 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 3976324
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:47:27+00:00 2026-05-20T04:47:27+00:00

Me again :) I need to break line if it is longer than 78

  • 0

Me again 🙂
I need to break line if it is longer than 78 characters (including tab and spaces) and only in case it’s between patterns. Input looks like (digits may change):

— Pattern1 —
(tab here)2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 . . . 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2
…
(tab here)2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 . . . 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
— Pattern2 —

and i need:

— Pattern1 —
(tab here)2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 .. (up to 78chars and then)&
(rest of previous line goes here,unless it’s still more then 78chars, becouse than again)&
(and so on and on until the end of the line) .. 2 2
next line also cutted to 78char lines
and again
— Pattern2 —

To achieve this i need to use scripting in bash 2.05

  • 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-20T04:47:28+00:00Added an answer on May 20, 2026 at 4:47 am
    sed '/PATTERN1/,/PATTERN2/s/.\{78\}/&\n/g' ./infile
    

    Input

    $ cat ./infile
    fasdflkjsakfsalfjasd
    sadf
    saf
    saf
    123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I
    sadf
    sadfasfa
    START
    123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789123456789N123456789O123456789P
    END
    asf
    sadfas
    dfsad
    fsad
    fsad
    

    Output

    $ sed '/START/,/END/s/.\{78\}/&\n/g' ./infile
    fasdflkjsakfsalfjasd
    sadf
    saf
    saf
    123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I
    sadf
    sadfasfa
    START
    123456789A123456789B123456789C123456789D123456789E123456789F123456789G12345678
    9H123456789I123456789J123456789K123456789L123456789M123456789123456789N1234567
    89O123456789P
    END
    asf
    sadfas
    dfsad
    fsad
    fsad
    

    Edit

    If \n is not recognized by your version of sed. Try the following:

    $ sed '/START/,/END/s/.\{78\}/&\
    /g' ./infile
    

    In case that’s not clear, after the ampersand, ‘&’, put a backslash to tell the shell you want to do line continuation then press ENTER to insert a literal newline. Finally, when on the next line, finish up the command with /g' ./infile

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

Sidebar

Related Questions

I'm stuck.... Yet again. I need to add a line break after every 5
I need your help with this one again. I want to send special characters
I again need help by you, this time I struggle with covariance, contravariance, delegates
Once again I need your Help, am thanking you as every time you helped
I need your help again :) I'm trying to do a plugin with jQuery
I need your expertise once again. I have a java class that searches a
I need some help with jQuery script again :-) Just trying to play with
I need a form width a checkbox Don't show this again for my winform,
I need to clear drpAddressTypes dropdown values except the first item and bind again
me again... I need show 10 or 20 or 50 results number of results

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.