In the previous example, we defined a function called green. This leads into taking about some built-in functions that come with awk.
AWK comes with many built-in functions such as mathematical functions:
- sin(x)
- cos(x)
- sqrt(x)
- exp(x)
- log(x)
- rand()
You can use them like this:
$ awk 'BEGIN{x=sqrt(5); print x}'
Also, there are built-in functions that can be used in string manipulation:
$ awk 'BEGIN{x = "welcome"; print toupper(x)}'