Yeah, it's just like a normal INI file but happens to be on a Linux server. I've got a long awk line that now does the job too if anyone is interested in an awk-based solution:
Code:
awk 'BEGIN { FOUND=0 } /^\[Section2\]$/ {FOUND=1;next} /^\[.*\]$/ {FOUND=0} (if (FOUND==0) {print $0}; next}' input_file.cfg > input_file.cfg.new
This will create a new file, input_file.cfg.new, based on the processed input_file.cfg. So I guess a one-liner would look like this:
Code:
awk 'BEGIN { FOUND=0 } /^\[Section2\]$/ {FOUND=1;next} /^\[.*\]$/ {FOUND=0} (if (FOUND==0) {print $0}; next}' input_file.cfg > input_file.cfg.new; rm -f input_file.cfg; mv input_file.cfg.new input_file.cfg