I want to permanently enable a Linux repo from the command line in a file that contains the definitions of multiple repos. So the file looks something like :
[repo-first]
some config line
another config line
enabled=0
more config lines
[repo-second]
some config line
another config line
enabled=0
more config lines
I want to be able to selectively set 'enable=0' to 'enable=1' based on the repo name.
There seem to be multiple ways of sucking in the file and/or ignoring the line separator including -p0e, -0777, "BEGIN {undef $}...". My best guess so far is something like :
perl -0777 -e -pi "BEGIN { undef $/ } s/(\[repo\-first\]\n(.*\n)*?enabled\=)0/$1\1/mg" /etc/yum.repos.d/repo-def-file
But naturally, this doesn't work. Ideas?
-00. E.g.perl -00 -pi -e"next unless /\Q[repo-first]/; s/^enabled=\K0/1/m;" file. Though I have to say that Borodin's answer will work much better.-0777andBEGIN { undef $/ }are mutually exclusive, as they do the same thing.