IFS= read -r line 的意义

 

[root@netsa ~]# echo " a b c " |{ IFS= read -r line;echo "[$line]";}
[ a b c ]
[root@netsa ~]#
[root@netsa ~]# echo " a b c " |{ read -r line;echo "[$line]";}
[a b c]

 

意义在于是否保留空格转移,IFS= 代表读入的内容保留空格。

posted @ 2023-03-17 18:41  忙碌在路上  阅读(49)  评论(0编辑  收藏  举报