当前位置:网站首页>【一天学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())
}'获取一行

自定义函数

输出重定向(追加)

输出重定向(覆盖)
边栏推荐
- Using swiper to make mobile phone rotation map
- 雷神科技冲刺北交所,拟募集资金5.4亿元
- DirectX repair tool v4.1 public beta! [easy to understand]
- Summary of empty string judgment in the project
- A unifying review of deep and shallow anomaly detection
- What if you are always bullied because you are too honest in the workplace?
- solidty-基础篇-结构体和数组,私有 / 公共函数,函数的返回值和修饰符,事件
- Recommendation of data acquisition tools and detailed graphic process of data acquisition list
- 微信小程序03-文字一左一右显示,行内块元素居中
- Junda technology indoor air environment monitoring terminal PM2.5, temperature and humidity TVOC and other multi parameter monitoring
猜你喜欢
![[advanced ROS] lesson 5 TF coordinate transformation in ROS](/img/4d/ae7d477bf6928005e16f046d461dcb.png)
[advanced ROS] lesson 5 TF coordinate transformation in ROS

Recommendation of data acquisition tools and detailed graphic process of data acquisition list

opencv学习笔记六--图像拼接

《QT+PCL第九章》点云重建系列2

微信公众号订阅消息 wx-open-subscribe 的实现及闭坑指南

MySQL审计插件介绍

微信小程序02-轮播图实现与图片点击跳转

Filter & (login interception)

Opencv learning notes 5 -- document scanning +ocr character recognition

JVM第一话 -- JVM入门详解以及运行时数据区分析
随机推荐
Beilianzhuguan joined the dragon lizard community to jointly promote carbon neutralization
JVM第二话 -- JVM内存模型以及垃圾回收
常见健身器材EN ISO 20957认证标准有哪些
Apk signature principle
The difference between arrow function and ordinary function in JS
openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题
S32K1xx 微控制器的硬件設計指南
An intrusion detection model
MongoDB第二话 -- MongoDB高可用集群实现
Flink 系例 之 TableAPI & SQL 与 MYSQL 插入数据
这3款在线PS工具,得试试
Implementation of wechat web page subscription message
Tableapi & SQL and MySQL grouping statistics of Flink
MySQL审计插件介绍
In hot summer, please put away this safe gas use guide!
微信小程序01-底部导航栏设置
Using swiper to make mobile phone rotation map
MySQL审计插件介绍
Mongodb second call -- implementation of mongodb high availability cluster
数字化转型:数据可视化赋能销售管理

