You could probably use a look-ahead and anchor the the beginning of the line.
perl -pi.BAK -e 's{^(?=Defaults\s+(?:env_reset|requiretty))}{#}'
I hope this is helpful.
Cheers,
JohnGG
In reply to Re: Perl search and replace
by johngg
in thread Perl search and replace
by austin43
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |