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

边栏推荐
- 功能测试报告的编写
- EasyExcel 复杂数据导出
- Flume interview questions
- String type conversion BigDecimal, date type
- Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
- Several ways of writing main function in C
- Can you get a raise? Analysis on gold content of PMP certificate
- Yyds dry goods inventory # solve the real problem of famous enterprises: egg twisting machine
- IDA动态调试apk
- 【juc学习之路第8天】Condition
猜你喜欢

园区全光技术选型-中篇

I received a letter from CTO inviting me to interview machine learning engineer

C#/VB.NET 给PDF文档添加文本/图像水印

Sonic云真机学习总结6 - 1.4.1服务端、agent端部署

MIT|256KB 内存下的设备上训练

【MySQL】索引的分类

AirServer2022最新版功能介绍及下载

功能测试报告的编写

MySQL MHA high availability configuration and failover

Microsoft, Columbia University | Godel: large scale pre training of goal oriented dialogue
随机推荐
YOLOv5.5 调用本地摄像头
Is PMP certificate really useful?
The leader of the cloud native theme group of beacon Committee has a long way to go!
【juc学习之路第9天】屏障衍生工具
详解ThreadLocal
20220701
Airserver mobile phone third-party screen projection computer software
GaussDB(DWS)主动预防排查
信标委云原生专题组组长,任重道远!
Mysql——》MyISAM存储引擎的索引
Unity 使用Sqlite
详解Kubernetes网络模型
Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
灵动微 MM32 多路ADC-DMA配置
Pytorch sharpening chapter | argmax and argmin functions
H5 model trained by keras to tflite
MySQL之MHA高可用配置及故障切换
C#/VB.NET 给PDF文档添加文本/图像水印
Communication between browser tab pages
黑马程序员-软件测试--06阶段2-linux和数据库-01-08第一章-linux操作系统阶段内容说明,linux命令基本格式以及常见形式的说明,操作系统的常见的分类,查看命令帮助信息方法,