O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The gensub (regex, replacement, occurrence, [ string ]) function

gensub stands for general substitution. It adds more features that are not available in the sub() and gsub() functions. With gensub(), we can specify the number of occurrences of the matched regular expression that is to be replaced. It returns the modified string as the result of executing the function, and the original string is not changed. Its syntax is as follows:

gensub ( regex for original-string, replacement-string, occurrence-number, [string] )
  • regex for original-string: This is the original string that needs to be replaced. This can also be a regular expression.
  • replacement-string: This is the new string that is to be used for substitution.
  • Occurrence-number: This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required