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:02:14
Try double-escaping the special chars:

  sed s/\\&\\/\\n\\/g filename >filename2

This way, you're actually escaping the \ characters which can then be
passed on to sed where the (single) backslash will escape the following
character. 

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  |
------------------------------------------------------------------------------