当前位置:网站首页>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 .
边栏推荐
- Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)
- [image enhancement] vascular image enhancement based on frangi filter with matlab code
- Penser au jeu 15: penser au service complet et au sous - service
- Just using the way and method of consuming the Internet to land and practice the industrial Internet will not bring long-term development
- 学习笔记3--高精度地图关键技术(上)
- 6-3漏洞利用-SSH环境搭建
- matlab 使用 resample 完成重采样
- How can I batch produce the same title for the video?
- 浅浅了解Servlet
- Should enterprises choose server free computing?
猜你喜欢

Implementation of Weibo system based on SSM

Appium inspector can directly locate the WebView page. Does anyone know the principle

Using tabbar in wechat applet

This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable

Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage

【图像增强】基于Frangi滤波器实现血管图像增强附matlab代码

How to compress video size while adding watermark with one click?

Have you stepped on the nine common pits in the e-commerce system?

Matlab uses audioread and sound to read and play WAV files
![[IVX junior engineer training course 10 papers to get certificates] 0708 news page production](/img/ad/a1cb672d2913b6befd6d8779c993ec.jpg)
[IVX junior engineer training course 10 papers to get certificates] 0708 news page production
随机推荐
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
NeRV: Neural Reflectance and Visibility Fields for Relighting and View Synthesis
Private project practice sharing [Yugong series] February 2022 U3D full stack class 009 unity object creation
[IVX junior engineer training course 10 papers to get certificates] 01 learn about IVX and complete the New Year greeting card
[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games
k线图形态这样记(口诀篇)
Look at the industrial Internet from a new perspective and seek the correct ways and methods of industrial Internet
Brief description of grafana of # yyds dry goods inventory # Prometheus
Android: how can golden nine and silver ten squeeze into the first-line big factories from small and medium-sized enterprises? The depth of interview questions in large factories
Datawhale community blackboard newspaper (issue 1)
The technology boss is ready, and the topic of position C is up to you
Brief introduction to the development of mobile network
Penser au jeu 15: penser au service complet et au sous - service
Architecture evolution from MVC to DDD
浅浅了解Servlet
Exclusive delivery of secret script move disassembly (the first time)
Learning note 3 -- Key Technologies of high-precision map (Part 1)
Implementation of Weibo system based on SSM
The concept and application of Cartland number
企业应该选择无服务器计算吗?