Afficher un message
Vieux 21/08/2006, 17h09   #2
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sed problem: variables countaining special symbols

On 2006-08-21, Andy B wrote:
> Hi Guys,
>
> Wonder if you can , this problem is getting me down.
>
> My script is falling over with a sed problem.
>
> NEWSTORE=JvHCdEMzDegPI
> NPASS=EoWH/Q4hds7nA
>
> sed -e '/bill/s/'"${NEWSTORE}"'/'"${NPASS}"'/g' /tmp/temp
>
> The above sed command works fine when there are no "special characters"
> but when they appear as above i get a sed: command garbled: error.
> Tried a few things with no luck, to escape theses.


That's bacause $NPASS contains a slash. Use a different delimiter
with sed:

sed -e "/bill/s|${NEWSTORE}|${NPASS}|g" /tmp/temp

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
 
Page generated in 0,14452 seconds with 9 queries