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

边栏推荐
猜你喜欢
![[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial](/img/b0/029cdea72483ed9bc8a0d66908983a.png)
[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial

Ida dynamic debugging apk

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

详解JMM

leetcode - 287. 寻找重复数

Sonic cloud real machine learning summary 6 - 1.4.1 server and agent deployment

13th Blue Bridge Cup group B national tournament

2020-ViT ICLR

企业架构与项目管理的关联和区别

Relationship and difference between enterprise architecture and project management
随机推荐
[STM32] stm32cubemx tutorial II - basic use (new projects light up LED lights)
固定资产管理子系统报表分为什么大类,包括哪些科目
Why does blocprovider feel similar to provider?
Smart micro mm32 multi-channel adc-dma configuration
CSDN购买的课程从哪里可以进入
Recent public ancestor (LCA) online practices
Introduction and download of the latest version of airserver2022
地图其他篇总目录
Classify boost libraries by function
BlocProvider 为什么感觉和 Provider 很相似?
String type conversion BigDecimal, date type
GenICam GenTL 标准 ver1.5(4)第五章 采集引擎
RestTemplate 远程调用工具类
[monomer] recommended configuration of streaming information i-bpsv3 server
Clean up system cache and free memory under Linux
企业架构与项目管理的关联和区别
MySQL数据库详细学习教程
Unity 使用Sqlite
100年仅6款产品获批,疫苗竞争背后的“佐剂”江湖
MySQL series transaction log redo log learning notes