Awk Functions: What functions can I use?

Awk is such a useful program that there are several versions of it out there. The most notable ones are awk, nawk (or new awk), and gawk (or gnu awk). There is also an implementation of awk for DOS, which is roughly the same as nawk.

This page lists which functions are available in each version of awk. I am building the list based on my own experience, questions from readers, and occasional research. If you find a version of awk, or a function, that is not listed here, or if you find an error on these pages, write to Rob to let me know about it.

Functionawknawkgawk DOS awk
cos(x)YESYESYESYES
exp(x)YESYESYESYES
int(x)YESYESYESYES
log(x)YESYESYESYES
sin(x)YESYESYESYES
sqrt(x)YESYESYESYES
index(s,t)YESYESYESYES
length(s)YESYESYESYES
split(s,a,sep)YESYESYESYES
sprintf("fmt",expr)YESYESYESYES
substr(s,p,n)YESYESYESYES
system(s)noYESYESYES
atan2(y,x)noYES?YES
rand()noYES?YES
srand(x)noYES??
gsub(r,s,t)noYES?YES
match(s,r)noYES?YES
sub(r,s,t)noYES?YES
tolower(s)noYESYES? In fact, in nawk, these handle
international characters
toupper(s)noYESYES?


- Back to the main awk page
- Go to the programmer's soapbox
- Visit Grannus' Circle
- Back to the front gate.

Engage brain before putting mouth in gear
anon

Page maintained by Rob.