当前位置:网站首页>awk从入门到入土(16)awk变量类型探讨--关于数字和string两种类型
awk从入门到入土(16)awk变量类型探讨--关于数字和string两种类型
2022-07-28 06:13:00 【奇妙之二进制】
awk(变量、数组元素和字段)中的标量对象是动态类型的。这意味着它们的类型可以随着程序的运行而改变,从使用前的无类型,到字符串或数字,然后从字符串到数字或从数字到字符串,随着程序的进行。
你不能对无类型变量做很多事情,除了告诉它们是无类型的。以下程序针对a进行测试;当a从未被赋值时,测试成功。它还使用内置typeof()函数来显示a的类型:
$ gawk 'BEGIN { print (a == "" && a == 0 ?
> "a is untyped" : "a has a type!") ; print typeof(a) }'
a is untyped
unassigned
类似地,给标量赋予字符串值时,标量就具有字符串类型,例如来自字符串常量或来自另一个具有字符串类型的标量:
gawk 'BEGIN { a = 42 ; print typeof(a) ;b = a ; print typeof(b) }'
到目前为止,这一切都简单明了。但是,当awk处理来自用户的数据时会是怎么样呢?让我们从现场数据开始。以下命令应该产生什么作为输出?
echo hello | awk '{ printf("%s %s < 42\n", $1,
($1 < 42 ? "is" : "is not")) }'
由于’hello’是字母数据,awk只能做字符串比较。在内部
边栏推荐
- EMC中class A和class B哪个更严格?
- Discrimination coverage index / index coverage / Samsung index
- 干货|分享一个EMC实际案例及整改过程
- How to understand CMS collector to reduce GC pause time
- ArcGIS JS自定义Accessor,并通过watchUtils相关方法watch属性
- EMC整改方法集合
- Essential performance optimization topics in the interview~
- Soft exam certificate can be used like this! Get a certificate = get a professional title?
- After learning the four redis cluster solutions at one go, each has its own merits
- Synthesis of dna-ag2sqds DNA modified silver sulfide Ag2S quantum dots
猜你喜欢

win系统添加打印机

项目经历总结

【google】解决google浏览器不弹出账号密码保存框且无法保存登录信息问题

Matplotlib绘图笔记基础直线、折线、曲线

Deeply analyze the implementation of singleton mode

How low-end computers learn secrets in depth - using the mistgpu computing platform

干货|分享一个EMC实际案例及整改过程

DNA modified osmium OS nanoparticles osnps DNA modified iridium nanoparticles irnps DNA

常用电子产品行业标准及认证

JUC atomic class: CAS, unsafe, CAS shortcomings, how to solve ABA problems in detail
随机推荐
演讲笔记 适合所有人的实用程序生成 PCG
两个链表的第一个公共节点——每日两题
Isolation level RR, gap lock, unreal reading
mysql:LIKE和REGEXP操作有什么区别?
MHA high availability configuration and failover
收藏 | 结合个人经验,我总结了这7点EMC相关知识
【jvm优化超详细】常见的JVM调优场景
细说共模干扰和差模干扰
辨析覆盖索引/索引覆盖/三星索引
Merge two sorted linked lists - two questions per day
(每日一题)——最长不含重复字符的子字符串
【着色器实现Negative反色效果_Shader效果第十一篇】
DNA-Ag2SQDs脱氧核糖核酸DNA修饰硫化银Ag2S量子点的合成方法
【google】解决google浏览器不弹出账号密码保存框且无法保存登录信息问题
How low-end computers learn secrets in depth - using the mistgpu computing platform
Dry goods | share an EMC actual case and rectification process
0727~ sorting out interview questions
PCB design skills of EMC
Matplotlib绘图笔记基础直线、折线、曲线
After learning the four redis cluster solutions at one go, each has its own merits