sed within `` in Bourn Shell isn't Working.
Johnny Rosenberg
gurus.knugum at gmail.com
Sat Mar 21 19:16:12 UTC 2009
2009/3/21 Martin McCormick <martin at dc.cis.okstate.edu>
> 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.
I don't know, I got the same error, but there is an alternate method of
doing the same thing, and it worked for me:
#! /bin/sh
uid=$(echo "ABC\DEF" | sed 's/\\//g')
echo ${uid}
J.R.
>
>
> Martin McCormick WB5AGZ Stillwater, OK
> Systems Engineer
> OSU Information Technology Department Telecommunications Services Group
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20090321/5305ae03/attachment.html>
More information about the ubuntu-users
mailing list