sed within `` in Bourn Shell isn't Working.

Smoot Carl-Mitchell smoot at tic.com
Sat Mar 21 18:57:51 UTC 2009


On Sat, 2009-03-21 at 19:35 +0100, Thomas Kaiser wrote:
> Martin McCormick wrote:

> Try this:
> uid=`echo "ABC\DEF" | sed 's/\\\/\\\\\\\/g'`; echo $uid

Why not just:

uid='ABC\\DEF'

The single quotes protect the backslashes from being interpreted by the
shell. If you need to expand a variable in the string, you can do
something like:

uid="$var"'\\'"rest of string"

Shell quoting gets rather convoluted when you push strings to a subshell
which is what the `` construct does.


-- 
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list