• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 770
  • Last Modified:

Debian SED command, Multiple line search and replace

I have a config file that I am trying to edit with sed. Currently I am searching one line and replacing and it is working, but I would like to search and replace multiple lines and I am not sure on the correct command.

sudo sed -e "s/anonymous_enable=YES/anonymous_enable=NO/g" /etc/vsftpdbackup.conf
*This above works great, but I have another line below that I need to replace.

The config file looks like this:
local_enable=NO      **needs to be yes
write_enable=YES     **need to comment this out with #
1 Solution

sudo sed "s/anonymous_enable=YES/anonymous_enable=NO/g;s/local_enable=NO/local_enable=YES/;s/^write_enable=/#&/" /etc/vsftpdbackup.conf

Open in new window

If you want to modify the file as well, use sudo sed -i ...
LeviDailyAuthor Commented:
Thanks, that works!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now