in reply to Updating a conf file non-destructively
Your blob of code aside, don't underestimate the one-liner.
perl -i -pe 's/^sshd_enable=".*?"/sshd_enable="YES"/' /etc/rc.conf
Additionally: If you really want you can even get fancy:
perl -i -pe 's/^sshd_enable="(.*?)"/qq{sshd_enable="} . ( $1 eq "YES" +? "NO" : "YES" ) . qq{"}/e' /etc/rc.conf
|
|---|