I am trying to add a new line containing GATEWAY=10.0.10.1
to the /etc/sysconfig/network
file on each of 32 slave nodes in a cluster.
I read this post on how to insert a line with sed.
This works for me to add a line to a local file:
sed -i.bak -e "\$aGATEWAY=10.0.10.1" test/test1
This works for me viewing a file on node 32:
pdsh -w n032 cat test/test1
This fails for me trying to add a line to a file on node 32:
pdsh -w n032 sed -i.bak -e "\$aGATEWAY=10.0.10.1" test/test1
With this error:
n032: sed: -e expression #1, char 2: extra characters after command
pdsh@admin: n032: ssh exited with exit code 1
I own the file that I'm trying to change:
pdsh -w n032 ls -al test/test1
The above command shows that I own it and have read and write (rw
) permissions.
Why does it fail?
sed
. Probably you have to escape in a different way the expression "$aGATEWAY=10.0.10.1" that should be expanded by your local shell. – Hastur Jul 10 '14 at 08:12"\$aGATEWAY=10.0.10.1"
is escaped perfectly well as far as I can tell. What do you mean? – mikeserv Jul 10 '14 at 08:14sed -i.bak -e =10.0.10.1 test/test1
... – Hastur Jul 10 '14 at 08:20ssh "sed ... -e "\$a...""
- anyway you're definitely right about the error - nothing to do with the file. – mikeserv Jul 10 '14 at 08:21'
asssh sed -e '"\$a..."'
. – Hastur Jul 10 '14 at 11:12