当前位置:网站首页>[one day learning awk] use of built-in variables
[one day learning awk] use of built-in variables
2022-06-30 12:46:00 【Programmer Xiao Li】
1. ARGC、ARGV
ARGC Represents the number of variables (Argument Count)
ARGV Represents variable content (Argument Variable)
awk 'BEGIN{
for (i = 0; i < ARGC; ++i){
printf "args[%d]=%s\n", i, ARGV[i]
}
}' arg0, arg1, arg2, arg3, arg4We found that ,awk Is the first parameter , Other parameters are from 1 At the beginning :

Use here ARGC A cycle was carried out ,ARGV Is an array , Traversable .
2. Format symbol CONVFMT
awk 'BEGIN{print "FORMAT=", CONVFMT}'
3. environment variable ENVIRON
Use ENVIRON Get environment variables , The values of specific environment variables can be executed env see
awk 'BEGIN{print ENVIRON["USER"]}'
4. Get the file name FILENAME
awk 'END{print FILENAME}' marks.txt
5. NF、NR、FNR
NF A number of columns (Number Field)
NR Number of lines (Number Row)
FNR And NR similar , When multiple files , Different documents are numbered separately
Print the number of columns and data :
Print line numbers and data :

6. FS、RS、OFS、ORS、OFMT
FS Indicates the input column split symbol (Field Split), Default is space

RS Indicates the input newline character (Row Split), The default is \n

OFS Is the output column split symbol (Field Split), Default is space

ORS Indicates the output newline character (Row Split), The default is \n

OFMT Presentation output format , Default %.6g

7. RSTART And RLENGTH
RSTART Indicates the position of the first match
RLENGTH Indicates the length of the first match

8. $n What column do you want to get

9. Wrong content ERRNO
边栏推荐
- Redis - problèmes de cache
- Questionnaire star questionnaire packet capturing analysis
- SuperMap iDesktop 常见倾斜数据处理全流程解析
- 【一天学awk】内置变量的使用
- 药店管理系统
- 【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(二)
- 【 surprise】 la vitesse de téléchargement de Thunderbolt n'est pas aussi rapide que celle de la machine virtuelle
- Substrate 源码追新导读: 质押额度大幅度削减, RocksDB可以完全被Disable
- NoSQL - redis configuration and optimization
- 电机控制Clarke(α/β)等幅值变换推导
猜你喜欢

SuperMap 3D SDKs_Unity插件开发——连接数据服务进行SQL查询

腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?

黑马笔记---集合(Collection的常用方法与遍历方式)

How to use AI technology to optimize the independent station customer service system? Listen to the experts!

【惊了】迅雷下载速度竟然比不上虚拟机中的下载速度

Hisilicon 3559 developing common sense reserves: a complete explanation of related terms

SuperMap 3D SDKs_ Unity plug-in development - connect data services for SQL queries

【 surprise】 la vitesse de téléchargement de Thunderbolt n'est pas aussi rapide que celle de la machine virtuelle

Lichuang EDA learning notes 10 common connector component identification and passive buzzer driving circuit

Hisilicon 3559 universal platform construction: introduction to YUV format
随机推荐
RDS MySQL数据迁移PolarDB MySQL费用可以转过去吗?
Redis的配置文件及新数据类型
MySQL built-in functions
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matchin问题
MySQL中变量的定义和变量的赋值使用
Android development interview real question advanced version (with answer analysis)
全面解析免费及收费SSH工具的基本特性和总结
Redis installation on Linux system
【OpenGL】OpenGL Examples
Double dqn notes
Wechat launched the picture big bang function; Apple's self-developed 5g chip may have failed; Microsoft solves the bug that causes edge to stop responding | geek headlines
Commands for redis basic operations
MySQL判断执行条件为NULL时,返回0,出错问题解决 Incorrect parameter count in the call to native function ‘ISNULL‘,
【惊了】迅雷下载速度竟然比不上虚拟机中的下载速度
ffmpeg 杂项
时空预测2-GCN_LSTM
Building of Hisilicon 3559 universal platform: obtaining the modified code of data frame
How to use the plug-in mechanism to gracefully encapsulate your request hook
Tencent two sides: @bean and @component are used on the same class. What happens?
【一天学awk】数组的使用