Subject: Re: Off topic, read if you want to
To: Greg Evans <macguru@concord.televar.com>
From: Paul Goyette <paul@pgoyette.bdt.com>
List: port-mac68k
Date: 03/26/1997 04:50:29
Actually, you can do it like this (having just tried it):

# sed 's/\&/\\\
/' filename1 >filename2


At least under csh (and derivatives), the way to include a new-line
character in the command is to escape it and include the whole thing in
apostrophes or quotes.  The extra two \\ characters are so you can pass a
single \ escape character to sed, since it requires the newline to be
escaped, too.

On Wed, 26 Mar 1997, Greg  Evans wrote:

> I realize that this is *very* off topic, however everyone here has helped
> me in the past, so I'll as those I consider friends first.
> 
> I am trying to use 'sed' to go through a file and replace all occurrences
> of the '&' character with a <newline> or <return>, so that text like this:
> 
> email_address=username@isp.com&computer_type=Macintosh&Modemspeed=288
> 
> will look like this:
> 
> email_addres=username@isp.com
> computer_type=Macintosh
> Modemspeed=288
> 
> I have been using the following:
> 
> sed s/\&\/\n\/g filename >filename2
> sed s/\&\/\\n\/g filename >filename2
> 
> as well as many undocumented attempts at this.  The result always seems to
> be:
> 
> email_address=username@isp.comncomputer_type=MacintoshnModemspeed=288
> 
> As you see the '&' gets replaced but not with the '\n' (newline?) but with
> the character n.
> 
> Help please....
> 
> 
> Regards,
> 
> Greg Evans

------------------------------------------------------------------------------
| Paul Goyette       | PGP Public Key fingerprint:  | E-mail addresses:      |
| Network Consultant |     0E 40 D2 FC 2A 13 74 A0  |  paul@pgoyette.bdt.com |
| and kernel hacker  |     E4 69 D5 BE 65 E4 56 C6  |  paul_goyette@ins.com  |
------------------------------------------------------------------------------