当前位置:网站首页>There are spaces in the for loop variable in the shell -- IFS variable
There are spaces in the for loop variable in the shell -- IFS variable
2022-07-02 01:35:00 【Reef of】
- In the use of shell Of for loop , If there is a space in the middle of the string of the loop , Then the loop will be automatically divided , Here's the solution
Just change shell The separator is just
stay for Modify before loop IFS Variable , Example :
OLDIFS="$IFS" # Back up old IFS Variable
IFS=$'\n' # Change the separator to newline
for i in `cat aaa` #aaa The public key is stored in the file
do
echo "$i"
done
IFS="$OLDIFS" # Restore IFS Variable
- notes :
IFS Information about variables :
- Shell Put variables IFS Every character in is treated as a
Separator (delimeter), Use these characters as the terminator of each field for segmentation . - If IFS No settings , perhaps IFS The value of is set to
"\t\n"(space, tab and newline), Then all the at the beginning and end of the operation object space, tab and newline Sequences will be ignored , But in the middle of the operation object space, tab and newline The sequence will work as a delimiter . - If IFS It's not worth it
The default value is ( For example, in the program IFS It has been set ), Only in IFS White space characters in ( May be space, tab or newline One or more of ) Will be ignored at the beginning and end of the word , Here are words , Instead of the entire operation object . - IFS When more than one non white space character in the appears consecutively , Each non white space character is treated as a separate separator , But multiple consecutive white space characters are treated as a separator .
- If IFS It's empty (“null”), Word segmentation is not performed .
边栏推荐
- [IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production
- Day 13 of hcip (relevant contents of BGP agreement)
- 企业应该选择无服务器计算吗?
- TSINGSEE青犀平台如何实现同一节点同时播放多个视频?
- Laravel artisan 常用命令
- KS006基于SSM实现学生成绩管理系统
- 【疾病检测】基于BP神经网络实现肺癌检测系统含GUI界面
- Introduction to ffmpeg Lib
- Memorabilia of domestic database in June 2022
- Brief introduction to the development of mobile network
猜你喜欢

Matlab uses resample to complete resampling

Android high frequency network interview topic must know and be able to compare Android development environment

【图像增强】基于Frangi滤波器实现血管图像增强附matlab代码
![[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production](/img/dc/e9adb1b41c2175c6f18d8027e0530a.jpg)
[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production

Single chip microcomputer -- hlk-w801 transplant NES simulator (III)

6-2漏洞利用-ftp不可避免的问题

This is the form of the K-line diagram (pithy formula)

Liteos learning - first knowledge of development environment

How can I batch produce the same title for the video?

Learning notes 25 - multi sensor front fusion technology
随机推荐
Modeling essays series 124 a simple coding method
Learning note 3 -- Key Technologies of high-precision map (Part 1)
How does schedulerx help users solve the problem of distributed task scheduling?
机器学习基本概念
Self drawing of menu items and CListBox items
[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production
Altium designer measure distance (ctrl+m)
The role of artificial intelligence in network security
MySQL application day02
Exclusive delivery of secret script move disassembly (the first time)
II Basic structure of radio energy transmission system
6-3 vulnerability exploitation SSH environment construction
Android high frequency network interview topic must know and be able to compare Android development environment
Unity AssetBundle subcontracting
[image enhancement] vascular image enhancement based on frangi filter with matlab code
学习笔记24--多传感器后融合技术
[Floyd] post disaster reconstruction
Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
Using tabbar in wechat applet
只是以消费互联网的方式和方法来落地和实践产业互联网,并不能够带来长久的发展