mickt
asked on
What is sed command to edit line that includes quotes and spaces?
I'm trying to edit a line in a file as follows
sed -i 's@#filter = [ "a/.*/" ]@filter = [ "a/sda/", "a/sdb/", "a/sdc/", "r/.*/" ]@g' /etc/lvm/lvm.conf
It does not work. I've tried enclosing in quotes etc. but without success.
Can anyone advise as to the correct command?
sed -i 's@#filter = [ "a/.*/" ]@filter = [ "a/sda/", "a/sdb/", "a/sdc/", "r/.*/" ]@g' /etc/lvm/lvm.conf
It does not work. I've tried enclosing in quotes etc. but without success.
Can anyone advise as to the correct command?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If I try to include above in ssh I receive an error:
# ssh $i sed -i 's@#filter = \[ "a/.*/" ]@filter = [ "a/sda/", "a/sdb/", "a/sdc/", "r/.*/" ]@g' /etc/lvm/lvm.conf
sed: -e expression #1, char 8: unterminated `s' command
I can resolve as follows but I'd prefer to not use EOF if possible.
ssh $i <<EOF
ssh $i sed -i 's@filter = \[ "a/.*/" ]@filter = [ "a/sda/", "a/sdb/", "r/.*/" ]@g' /etc/lvm/lvm.conf
exit
EOF
# ssh $i sed -i 's@#filter = \[ "a/.*/" ]@filter = [ "a/sda/", "a/sdb/", "a/sdc/", "r/.*/" ]@g' /etc/lvm/lvm.conf
sed: -e expression #1, char 8: unterminated `s' command
I can resolve as follows but I'd prefer to not use EOF if possible.
ssh $i <<EOF
ssh $i sed -i 's@filter = \[ "a/.*/" ]@filter = [ "a/sda/", "a/sdb/", "r/.*/" ]@g' /etc/lvm/lvm.conf
exit
EOF
ASKER
Change from:
#filter = [ "a/.*/" ]
to:
filter = [ "a/sda/", "a/sdb/", "a/sdc/", "r/.*/" ]