Re: Editing a text file with sed
On Wed, Aug 29, 2007 at 03:17:46PM +0200, 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:
>
> sed s/\n// / 1.txt > 2.txt and I get an error, so:
> sed s'\n/ /' 1.txt > 2.txt and nothing happens.
>
> I don't get it. I though \n was end of line, which I am trying to replace
> with spaces.
>
sed works line by line, separately. There's an N modifier to make it
work across lines. You may check
http://www.panix.com/~elflord/unix/sed.html for a nice tutorial, or
http://www-h.eng.cam.ac.uk/help/tpl/unix/sed.html for some examples.
Regards,
Victor
Reply to: