I am trying to manipulate the same text file across multiple hosts. The command I currently have it:
for host in $(cat /etc/hosts | grep text | cut -d' ' -f 1 | sort -u); do
ssh $host \
sudo sed -i "s/enabled = 1/enabled = 0/" /etc/yum.repos.d/testing.repo
done
The sed command itself works locally on the host with no problems however when I run it here, I get:
sed: -e expression #1, char 9: unterminated `s' command
What am I doing wrong?
Try this,
for host in $(grep test /etc/hosts | cut -d' ' -f 1 | sort -u); do
ssh $host 'sudo sed -i "s/enabled = 1/enabled = 0/" /etc/yum.repos.d/testing.repo'
done
we should wrap around the remote commands with quotes.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments