linux-tutorial/codes/shell/逻辑控制/从命令读取值.sh

20 lines
335 B
Bash
Raw Normal View History

2019-10-29 18:22:19 +08:00
#!/usr/bin/env bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
#reading values from a file
file="state"
#更改字段分隔符,使其只能识别换行符
IFS=$'\n'
#处理长脚本是,在一个地方修改了该值,然后可能忘了修改过该值
#IFS.OLD=$IFS
#IFS=$'\n'
#具体代码
#IFS=$IFS.OLD
for state in `cat $file`
do
2019-10-29 18:22:19 +08:00
echo "Visit beautiful $state"
2019-05-10 11:17:57 +08:00
done