[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Editing a text file with sed



On 08/29/2007 08:17 AM, Joe Hart wrote:
I am having trouble using sed to edit text files, heres a good example of what I am looking for:

<begin 1.txt>
This is a test
file, what I am
trying to do is get the lines to join.

It isn't a complicated thing,
but I also want to keep the paragraphs
separate.
</end 1.txt>

I try this command:
[...]

Here's another Perl solution:

perl -00 -pe 's/\n+(?!$)/ /g; s/\n\n$/\n/' myfile.txt

If you want to keep the blank lines between paragraphs, remove the second substitution.



Reply to: