当前位置:网站首页>【一天学awk】函数与自定义函数
【一天学awk】函数与自定义函数
2022-07-01 15:16:00 【程序员·小李】
内置函数
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() }'
打印时间
awk 'BEGIN {
print strftime("Time=%m/%d/%Y %H:%M:%S", SYSTIME())
}'
获取一行
自定义函数
输出重定向(追加)
输出重定向(覆盖)
边栏推荐
- Junda technology - wechat cloud monitoring scheme for multiple precision air conditioners
- 【目标跟踪】|模板更新 时间上下文信息(UpdateNet)《Learning the Model Update for Siamese Trackers》
- 采集数据工具推荐,以及采集数据列表详细图解流程
- Tableapi & SQL and MySQL insert data of Flink
- Task. Run(), Task. Factory. Analysis of behavior inconsistency between startnew() and new task()
- JS中箭头函数和普通函数的区别
- Summary of week 22-06-26
- Filter &(登录拦截)
- phpcms后台上传图片按钮无法点击
- ArrayList 扩容详解,扩容原理[通俗易懂]
猜你喜欢
Intelligent operation and maintenance practice: banking business process and single transaction tracking
智能运维实战:银行业务流程及单笔交易追踪
Survey of intrusion detection systems:techniques, datasets and challenges
【目标跟踪】|STARK
Junda technology - wechat cloud monitoring scheme for multiple precision air conditioners
做空蔚来的灰熊,以“碰瓷”中概股为生?
It's settled! 2022 Hainan secondary cost engineer examination time is determined! The registration channel has been opened!
入侵检测模型(An Intrusion-Detection Model)
Wechat applet 01 bottom navigation bar settings
openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题
随机推荐
Shopping mall 6.27 to be completed
贝联珠贯加入龙蜥社区,共同促进碳中和
Opencv Learning Notes 6 -- image mosaic
Introduction to MySQL audit plug-in
Solidty智能合约开发-简易入门
Opencv learning note 4 -- bank card number recognition
IDEA全局搜索快捷键(ctrl+shift+F)失效修复
网速、宽带、带宽、流量三者之间的关系是什么?
竣达技术丨多台精密空调微信云监控方案
Storage form of in-depth analysis data in memory
微信小程序02-轮播图实现与图片点击跳转
Junda technology - wechat cloud monitoring scheme for multiple precision air conditioners
Flink 系例 之 TableAPI & SQL 与 MYSQL 插入数据
Survey of intrusion detection systems:techniques, datasets and challenges
[leetcode] 16. The sum of the nearest three numbers
Flink 系例 之 TableAPI & SQL 与 MYSQL 分组统计
Wechat official account subscription message Wx open subscribe implementation and pit closure guide
ArrayList 扩容详解,扩容原理[通俗易懂]
项目中字符串判空总结
leetcode:329. Longest increasing path in matrix