当前位置:网站首页>内部字段分隔符
内部字段分隔符
2022-07-01 21:47:00 【云梦谭】
内部字段分隔符(Internal Field Separator,IFS)是shell脚本编程中的一个重要概念。在处理文本数据时,经常会用到。IFS本质上是保存了分隔符的变量。
比如说,有一个CSV文件,如果要提取单词, 可以使用 IFS=" ";如果要提取逗号分隔的字段值,则可以使用 IFS="," 。
提取CSV里的字段:
#!/bin/bash
data="Fist name, Last name, gender, rollno, location"
oldIFS=${IFS}
IFS=,
for item in ${data};
do
echo "Item : ${item}"
done
IFS=${oldIFS}
运行结果如下:
如果把IFS=,一行去掉。那么缺省的IFS将是空白字符。运行结果将变为:
边栏推荐
- [live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
- Qtreeview+qabstractitemmodel custom model: the third of a series of tutorials [easy to understand]
- Icml2022 | interventional contrastive learning based on meta semantic regularization
- LIS (longest ascending subsequence) problem that can be understood [easy to understand]
- CIO's discussion and Analysis on the definition of high-performance it team
- 地图其他篇总目录
- Copy ‘XXXX‘ to effectively final temp variable
- 园区全光技术选型-中篇
- Recent public ancestor offline practice (tarjan)
- 功能测试报告的编写
猜你喜欢
随机推荐
并发编程系列之FutureTask源码学习笔记
固定资产管理子系统报表分为什么大类,包括哪些科目
#yyds干货盘点# 解决名企真题:扭蛋机
CNN convolution neural network principle explanation + image recognition application (with source code) [easy to understand]
One of the basic learning of function
QT uses ffmpeg4 to convert the qimage of ARGB to yuv422p
MySQL数据库详细学习教程
Tops, the unit of computing power of the processor, can be carried out 1 trillion times per second
Recent public ancestor offline practice (tarjan)
BlocProvider 为什么感觉和 Provider 很相似?
【juc学习之路第8天】Condition
删除AWS绑定的信用卡账户
MIT|256KB 内存下的设备上训练
为什么数字化转型战略必须包括持续测试?
对象内存布局
Learn MySQL from scratch - database and data table operations
Learning notes on futuretask source code of concurrent programming series
详解JMM
What is the difference between PMP and NPDP?
【目标跟踪】|单目标跟踪指标