内置函数
sin(expr) 正弦值

cos(expre) 余弦

atan2(y,x) 反正切

exp(expr) 指数

log(expr) 对数

sqrt(expr) 平方根

int(expr) 整数

rand 随机数
srand([expr]) 随机数

数组排序
awk 'BEGIN{a[0] = "c"; a[1] = "b"; a[2] = "a"; asort(a); for (ele in a){print a[ele]}}'
按数组索引排序
awk 'BEGIN{a[0] = "c"; a[1] = "b"; a[2] = "a"; asorti(a); for (ele in a){print a[ele]}}'
字符串替换gsub("pattern", "content", str)
只替换一次用sub("pattern", "content", str)

字符串查找index(str, "pattern")

找到则返回位置,否则返回0
字符串长度length

正则匹配match(str, patten)

字符串分割split(str, array, "patten")

字符串转数字
awk 'BEGIN{str = "123"; print strtonum(str)}'
字符串截取substr(str, index, len)

大小写转换tolower(str) toupper(str)
不改变原来的字符串

时间戳
awk 'BEGIN{print SYSTIME() }'
打印时间
print strftime("Time=%m/%d/%Y %H:%M:%S", SYSTIME())
获取一行

自定义函数

输出重定向(追加)

输出重定向(覆盖)