0

machineName=machine1

Replace: MACHINEDOTS="'uname -n'" to MACHINEDOTS="machine1"

I tried the following sed cmd,

sed 's/MACHINEDOTS="'uname -n'"/MACHINEDOTS="'$machineName'"/g' tmp mv -f tmp path

Error displayed: sed: invalid option -- '"'

2 Answers 2

1

When I try to run your example on Mac OS X 10.7, I get an "unterminated substitute pattern" because you used a double quote " instead of either a single quote ' or a backquote `.

Replacing the double quote with a single quote and getting rid of the garbage after tmp (did you mean && mv -f tmp path ?) like this:

sed 's/MACHINEDOTS=''uname -n''/MACHINEDOTS="'$machineName'"/g' tmp 

works, but I'm not 100% sure whether this is what you want.

Sign up to request clarification or add additional context in comments.

Comments

0

sed 's/MACHINEDOTS="'uname -n'"/MACHINEDOTS="'$machineName'"/g' tmp mv -f tmp path

Do you mean to evaluate uname -n? It will need to be in back ticks. Like so:

$ sed 's/\(MACHINEDOTS="\)'`uname -n`'"/\1'$machineName'"/g'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.