我想用 IFS 来进行字符串分割,分割字符串的内容为 HELLOWORLD|*.py
分割字符串脚本 test_split.sh 如下:
OLD_IFS=${IFS} echo -e "OLD_IFS: ${OLD_IFS}" IFS='|' echo -e "IFS: ${IFS}"
STRING="HELLOWORLD|*.py" temp_str=[] temp_str=($STRING)
IFS=${OLD_IFS} echo -e "IFS: ${IFS}" echo -e "${temp_str[0]}" echo -e "${temp_str[1]}"
我想要的是将这个字符串分割为"HELLOWORLD"和"*.py"
但是因为我的 test_split.sh 同级目录里面有一个 test.py:
[root@VM-4-7-centos test_shell]# ls
这个脚本就自动将*.py 给我替换成为 test.py 了
我想请教一下为什么?如何解决这个问题?谢谢!
