bash中IFS变量的功能

当我们设置了变量IFS后,再使用echo输出时,会将所设定的字符用空格去代替。

 

IFS=$'\n'
echo `ls`
a.out c++ king.c test.c test.s test1.c test2.c
IFS=
echo `ls`
a.out
c++
king.c
test.c
test.s
test1.c
test2.c

上面两对指令的效果就是将每一项后的的回车换成了,空格。



 

你可能感兴趣的:(c,bash)