I just helped a friend out with placing a shell variable into a sed command and thought it would be prudent to document it.
This set of commands was to be used to change directory names inside a samba share, hense the directory names of \ and the unix escape needed making a bunch of \\ appear.
server_name# DIR=”blahblah”
server_name# echo “bob” | sed “s/^/${DIR}\\\ADMIND__${DIR}\\\/”
blahblah\ADMIND__blahblah\bob
Set the variable DIR to “blahblah”, I should have just used “foo” it’s less to type. Now echo the word “bob” but first add our variable and a prefix of “ADMIND__” to the front of bob.
I wanted to show another example, but don’t have time at the momment.
The important things to remember is to have the variables enclosed in double quotes.
