I want to find out which files under /etc have the the following section:
and then i would like to comment out the above section in all the files.
Please help.
I want to find out which files under /etc have the the following section:
and then i would like to comment out the above section in all the files.
Please help.
I am using the # character at the begining of the line. change it to reflect your idea of commenting out.
awk ' BEGIN{ ok=0 }
/BEGIN e-healthcare SETUP/ {print $0; ok=1; next}
/ END e-healthcare OAS SETUP/ {ok=0}
ok==1 {printf(" #")}
{print $0}' somefile > newfile
# only if this works for you
mv newfile somefile
to find files (under /etc ? really weird)
grep -l ' END e-healthcare OAS SETUP' /etc/*
Jim I like this.
Or if you want to include the headers as well:
sed '/BEGIN e-healthcare SETUP/,/END e-healthcare OAS SETUP/{s/^/# /;}' infile