- The REAL answer to this MULTILINE question was given here by Stephane https://unix.stackexchange.com/a/521560/354415
- Alternatively go line by line with perl by Terdon below: https://unix.stackexchange.com/a/521512/354415
- Alternatively go line by line with IFS by myself here: https://unix.stackexchange.com/a/521550/354415
Here is my new toy:
Problem is that I want it to match only on lines which do not have the #\s* in front of the parameter.
Please do not provide alternative code e.g. sed etc. use perl
perl -we 'my $file= "parameter=9 # parameter=10 parameter=10 "; $file=~ s/.*((?<!^# ))parameter\s*=.*/parameter=replaced/g; print(":$file:\n")'
parameter=replaced # parameter=10 parameter=replaced
PS if you are interested to see how I progressed with this, look here:Perl Negative Lookbehind with variable length bypass maybe?