In gawk, is it correct that
sub() don't consider the fields, and are not affected by change to
OFS? In other words, are they only concerned about records not fields? Thanks.
Those functions all work on a specific string that you pass to the function, or, in the case of
$0 (i.e. the complete input record) if you don't supply a string. They will not split the given string into fields or use either of
So, yes, none of these functions are affected by a change of
OFS. They are considering the given string as it is. If
$0 is used as the input string, this whole string is used unaltered.
This does not stop you from using e.g.
gsub() on a separate field, obviously.