Re: change paragraphs to long lines
Michael Hauser <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <20131116222130.GB13651@tessellated> |
Not that I've had the time to try this beautiful little snippet of code, but I am too hopeful that this or something similar makes it into the sed1line.txt, where it would've spared me hours of figuring it out by myself! ☺ *winks to sven* cheers, mih Daniel Goldman writes: > Let's hope this one makes it to the list. Last time, I forgot the default is to email the > person (private email), not the list. > > prem wrote: > > Would not something like this do the same in a simpler way? > > You may have to use something other than "~" if you think it might > > already exist in the input. > > > > tr "\n" "~" input | sed -e '/s/~~/\n/g' -e '/~/ /g' > output > > I modified your syntax some, there were some syntax mistakes (look below), but I agree it > is a simpler way. > > $ cat input > ONE two three one two three one two three one > TWO three one two three one two three one two > THREE one two three one two three one two > > ONE two three one two three one two three one > TWO three one two three one two three one two > THREE one two three one two three one two > > ONE two three one two three one two three one > TWO three one two three one two three one two > THREE one two three one two three one two > > $ tr "\n" "~" < input | sed -e 's/~~/\n\n/g' -e 's/~/ /g' > ONE two three one two three one two three one TWO three one two three one two three one > two THREE one two three one two three one two > > ONE two three one two three one two three one TWO three one two three one two three one > two THREE one two three one two three one two > > ONE two three one two three one two three one TWO three one two three one two three one > two THREE one two three one two three one two > > Daniel -- 'aware water' is an anagram for 'we are at war'