|
Home > Archive > Unix Shell > May 2007 > Spliting big line
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hello All ,
I'm trying to split one big line into many lines , the lines that i
want to split start with 'Text' string and end with 'End of Text'
string.
For example:
Text ABCDEFGHIJKLM End of Text Text AAAAAAAAAAAAAA End of Text ....
and i'm trying to generate
Text ABCDEFGHIJKLM End of Text
Text AAAAAAAAAAAAAA End of Text
.......
Any hint or help?
Thank you!!!
| |
| Janis Papanagnou 2007-05-24, 1:18 pm |
| Beto wrote:
> Hello All ,
>
> I'm trying to split one big line into many lines , the lines that i
> want to split start with 'Text' string and end with 'End of Text'
> string.
>
> For example:
>
> Text ABCDEFGHIJKLM End of Text Text AAAAAAAAAAAAAA End of Text ....
>
> and i'm trying to generate
>
> Text ABCDEFGHIJKLM End of Text
> Text AAAAAAAAAAAAAA End of Text
> ......
>
> Any hint or help?
Try...
sed "s/End of Text /&\n/g"
(if you don't mind the blank at the end of each line)
Janis
>
> Thank you!!!
>
| |
| Radoulov, Dimitre 2007-05-24, 7:18 pm |
|
"Beto" wrote ...
[...]
> I'm trying to split one big line into many lines , the lines that i
> want to split start with 'Text' string and end with 'End of Text'
> string.
>
> For example:
>
> Text ABCDEFGHIJKLM End of Text Text AAAAAAAAAAAAAA End of Text ....
>
> and i'm trying to generate
>
> Text ABCDEFGHIJKLM End of Text
> Text AAAAAAAAAAAAAA End of Text
[...]
With GNU Awk:
awk '{print $0RT}' RS="End of Text "
Dimitre
| |
| Robert Bonomi 2007-05-30, 1:25 pm |
| In article <1180028085.540803.24560@u30g2000hsc.googlegroups.com>,
Beto <andredigi@hotmail.com> wrote:
>Hello All ,
>
>I'm trying to split one big line into many lines , the lines that i
>want to split start with 'Text' string and end with 'End of Text'
>string.
>
>For example:
>
>Text ABCDEFGHIJKLM End of Text Text AAAAAAAAAAAAAA End of Text ....
>
>and i'm trying to generate
>
>Text ABCDEFGHIJKLM End of Text
>Text AAAAAAAAAAAAAA End of Text
>......
>
>Any hint or help?
Depending on the length of the 'line' you are dealing with,
the most practical way may be to write a small program to do it.
Many of the 'text utilities' *DO* have limits on the size of a 'line'
that they can deal with.
One fool-proof methodology is to use dd(1) to divide the line into
'reasonable' chunks, and then use something like awk(1) to process
the 'now-guaranteed-to-be-reasonable-length' lines. You do have to
include some extra logic to save any 'partial line' remainder from
the currently-processed 'chunk', and prepend it to the next chunk
read in before scanning _that_ chunk.
|
|
|
|
|