austin43 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I am trying to figure out how to automatically search and comment out specific lines within the /etc/sudoers file. I have the following lines to change...
I need them to look like...Defaults env_reset Defaults requiretty
I tried the following lines of code in backticks...#Defaults env_reset #Defaults requiretty
The ".+" is to match any number of characters before or after the phrase. I think I may be using it wrong, but I am not sure. Any thoughts or ideas are greatly appreciated. Thanks in advance!`perl -pi -e 's/.+Defaults env_reset.+/ #Defaults env_reset/g' /etc/sudoers` `perl -pi -e 's/.+Defaults requiretty.+/ #Defaults requiretty/g' /etc/sudoers`
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl search and replace
by johngg (Canon) on May 19, 2011 at 22:27 UTC | |
Re: Perl search and replace
by wind (Priest) on May 19, 2011 at 22:27 UTC | |
Re: Perl search and replace
by 7stud (Deacon) on May 19, 2011 at 23:02 UTC | |
Re: Perl search and replace
by apomatix (Novice) on May 19, 2011 at 22:44 UTC | |
Re: Perl search and replace
by eye (Chaplain) on May 20, 2011 at 06:38 UTC | |
Re: Perl search and replace
by thargas (Deacon) on May 20, 2011 at 11:50 UTC |
Back to
Seekers of Perl Wisdom