Solved

What is sed command to edit line that includes quotes and spaces?

Posted on 2015-01-28
3
73 Views
Last Modified: 2015-01-30
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?
0
Comment
Question by:mickt
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40575240
What do you want that line to do?
What is the line you want to edit, and what do you want the result to be?
Did you want something like this?
sed -i 's@#filter = \[ "a/.*/" ]@filter = [ "a/sda/", "a/sdb/", "a/sdc/", "r/.*/" ]@g'  /etc/lvm/lvm.conf
0
 

Author Comment

by:mickt
ID: 40575259
Good stuff.  Adding \ did the trick.

Change from:

#filter = [ "a/.*/" ]

to:

filter = [ "a/sda/", "a/sdb/", "a/sdc/", "r/.*/" ]
0
 

Author Comment

by:mickt
ID: 40579411
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
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now