当前位置:网站首页>[one day learning awk] function and user-defined function
[one day learning awk] function and user-defined function
2022-07-01 15:24:00 【Programmer Xiao Li】
Built in functions
sin(expr) Sine
cos(expre) cosine

atan2(y,x) Anyway

exp(expr) Index

log(expr) logarithm

sqrt(expr) square root

int(expr) Integers
rand random number
srand([expr]) random number

Array sorting
awk 'BEGIN{a[0] = "c"; a[1] = "b"; a[2] = "a"; asort(a); for (ele in a){print a[ele]}}'Sort by array index
awk 'BEGIN{a[0] = "c"; a[1] = "b"; a[2] = "a"; asorti(a); for (ele in a){print a[ele]}}'String substitution gsub("pattern", "content", str)
Replace only once sub("pattern", "content", str)

String search index(str, "pattern")

If found, return to the location , Otherwise return to 0
String length length

Regular matching match(str, patten)

String segmentation split(str, array, "patten")

String to number
awk 'BEGIN{str = "123"; print strtonum(str)}' String interception substr(str, index, len)

toggle case tolower(str) toupper(str)
Don't change the original string

Time stamp
awk 'BEGIN{print SYSTIME() }' Print time
awk 'BEGIN {
print strftime("Time=%m/%d/%Y %H:%M:%S", SYSTIME())
}'Get a row

Custom function

Output redirection ( Additional )

Output redirection ( Cover )
边栏推荐
猜你喜欢

竣达技术丨多台精密空调微信云监控方案

MySQL审计插件介绍

Markdown编辑器使用基本语法
![[leetcode] 16. The sum of the nearest three numbers](/img/60/6a68333d6e543c601e6ed586b830d0.png)
[leetcode] 16. The sum of the nearest three numbers
Implementation of deploying redis sentry in k8s

张驰课堂:六西格玛数据的几种类型与区别

Qt+pcl Chapter 9 point cloud reconstruction Series 2

厦门灌口镇田头村特色农产品 甜头村特色农产品蚂蚁新村7.1答案

Official announcement: Apache Doris graduated successfully and became the top project of ASF!

Intelligent operation and maintenance practice: banking business process and single transaction tracking
随机推荐
Hardware design guide for s32k1xx microcontroller
Connect the ABAP on premises system to the central inspection system for custom code migration
STM32F411 SPI2输出错误,PB15无脉冲调试记录【最后发现PB15与PB14短路】
What if you are always bullied because you are too honest in the workplace?
精益六西格玛项目辅导咨询:集中辅导和点对点辅导两种方式
Summary of week 22-06-26
Opencv Learning Notes 6 -- image feature [harris+sift]+ feature matching
Can I choose to open an account on Great Wall Securities? Is it safe?
22-06-26周总结
【ROS进阶篇】第五讲 ROS中的TF坐标变换
The last picture is seamlessly connected with the first picture in the swiper rotation picture
MySQL 服务正在启动 MySQL 服务无法启动解决途径
【锁】Redis锁 处理并发 原子性
《QT+PCL第九章》点云重建系列2
leetcode:329. Longest increasing path in matrix
微信小程序03-文字一左一右显示,行内块元素居中
SAP S/4HANA: 一条代码线,许多种选择
phpcms后台上传图片按钮无法点击
做空蔚来的灰熊,以“碰瓷”中概股为生?
张驰咨询:锂电池导入六西格玛咨询降低电池容量衰减

