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
Input
Output
Edit
If
\nis not recognized by your version ofsed. Try the following: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