You need to do:
echo foo.BAZ.bar | awk 'BEGIN{IGNORECASE = 1}{gsub(/[.]baz[.]/,".")}1'
When you put an explicit ;
after the IGNORECASE
statement, your line gets printed as is before any modification, since the action is returned true and awk
prints the line. Once gsub
gets to modify the line, the explicit print
then prints the modified line.
Also, notice the way, strings are kept in gsub
function.
Update: As stated in the comments by Ed, using the previous solution would test the IGNORECASE variable against every line. Putting it in BEGIN section assigns it once and uses it for entire file.