当前位置:网站首页>内部字段分隔符
内部字段分隔符
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将是空白字符。运行结果将变为:

边栏推荐
- QT 使用FFmpeg4将argb的Qimage转换成YUV422P
- 内存导致的电脑游戏中显示hdmi无信号 从而死机的情况
- mysql 学习笔记-优化之SQL优化
- Show member variables and methods in classes in idea
- Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
- String type conversion BigDecimal, date type
- H5 model trained by keras to tflite
- The correct way to set the bypass route
- Clean up system cache and free memory under Linux
- 删除AWS绑定的信用卡账户
猜你喜欢
随机推荐
linux下清理系统缓存并释放内存
YOLOv5.5 调用本地摄像头
快乐数[环类问题之快慢指针]
指标陷阱:IT领导者易犯的七个KPI错误
The difference between NiO and traditional IO
Matlab traverses images, string arrays and other basic operations
MySQL的视图练习题
详解ThreadLocal
Recent public ancestor (LCA) online practices
ICML2022 | 基于元语义正则化的介入性对比学习
Sonic云真机学习总结6 - 1.4.1服务端、agent端部署
比较版本号[双指针截取自己想要的字串]
[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial
Getting started with the lockust series
Training on the device with MIT | 256Kb memory
IDA动态调试apk
Sonic cloud real machine learning summary 6 - 1.4.1 server and agent deployment
Introduction and download of the latest version of airserver2022
awoo‘s Favorite Problem(优先队列)
Burpsuite simple packet capturing tutorial [easy to understand]









