当前位置:网站首页>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 .
边栏推荐
- 城市选择器组件实现原理
- 电子协会 C语言 1级 32、计算2的幂
- [IVX junior engineer training course 10 papers to get certificates] 09 chat room production
- 浅浅了解Servlet
- [Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility
- [rust web rokcet Series 1] Hello, world and get, post, put, delete
- Implementation of Weibo system based on SSM
- Just using the way and method of consuming the Internet to land and practice the industrial Internet will not bring long-term development
- Learning notes 25 - multi sensor front fusion technology
- Learning note 3 -- Key Technologies of high-precision map (Part 1)
猜你喜欢
![[IVX junior engineer training course 10 papers to get certificates] 09 chat room production](/img/a8/25215e74162b7ab3f29df65681932b.jpg)
[IVX junior engineer training course 10 papers to get certificates] 09 chat room production

Learn basic K-line diagram knowledge in three minutes

Matlab uses resample to complete resampling

卷积神经网络(包含代码与相应图解)

Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)

Memorabilia of domestic database in June 2022

Basic concepts of machine learning

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

SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5

卷積神經網絡(包含代碼與相應圖解)
随机推荐
Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
Memorabilia of domestic database in June 2022
The author is more willing to regard industrial Internet as a concept much richer than consumer Internet
Exclusive delivery of secret script move disassembly (the first time)
Docker installing Oracle_ 11g
[Floyd] post disaster reconstruction
Using tabbar in wechat applet
Design and implementation of radio energy transmission system
[rust web rokcet Series 2] connect the database and add, delete, modify and check curd
Learning notes 25 - multi sensor front fusion technology
[Chongqing Guangdong education] Tianshui Normal University universe exploration reference
Single chip microcomputer -- hlk-w801 transplant NES simulator (III)
Principle of finding combinatorial number and template code
Laravel artisan 常用命令
Appium inspector can directly locate the WebView page. Does anyone know the principle
Circular statements in shell programming
[disease detection] realize lung cancer detection system based on BP neural network, including GUI interface
只是以消费互联网的方式和方法来落地和实践产业互联网,并不能够带来长久的发展
6-2 vulnerability exploitation - inevitable problems of FTP
站在新的角度来看待产业互联网,并且去寻求产业互联网的正确方式和方法