sed within `` in Bourn Shell isn't Working.
Martin McCormick
martin at dc.cis.okstate.edu
Sat Mar 21 18:15:27 UTC 2009
I am doing something wrong but not sure what. This works
from the command line:
echo "ABC\DEF" | sed 's/\\//g'
What you get is ABCDEF without the \ character.
In a script, however, I am trying to replace the \ with
\\ and assign the output to a variable but the `` construct
seems to throw the whole thing off.
#! /bin/sh
uid=`echo "ABC\\DEF" | sed 's/\\/\\\\/g'`
echo $UID
I get an error like:
sed: -e expression #1, char 6: unterminated `s' command
I have actually tried this same script on a FreeBSD
system. That version of sed echos back the whole command and
also complains about the unterminated s command. The second ' is
right next to the ` so I know it's there but the `statements`
must be confusing things.
What am I missing here?
Thanks.
Martin McCormick WB5AGZ Stillwater, OK
Systems Engineer
OSU Information Technology Department Telecommunications Services Group
More information about the ubuntu-users
mailing list