【发布时间】:2023-11-01 04:48:01
【问题描述】:
我有一个属性文件 - 具有以下行的道具:
table1_prop=$USER.table1;dir1;dir2
在我的脚本中,我读取了文件,但无法评估 $USER。
while read record_line; do
if [ ! -z "$record_line" -a "$record_line" != " " ]; then
record_array=(`echo eval "$record_line" | cut -d '=' -f 2| sed 's/;/\n/g'`)
fi
done
评估不起作用。我试过反引号`。任何帮助。
【问题讨论】:
-
注意:
The XSI extensions specifying the -a and -o binary primaries and the '(' and ')' operators have been marked obsolescent(来自pubs.opengroup.org/onlinepubs/9699919799)也就是说,你应该写[ ! -z "$record_line" -a "$record_line" != " " ]而不是[ -n "$record_line" ] && [ "$record_line" != " " ]。 -
尝试类似:
while IFS='=.;' read a b c d e; do b=${b#$}; echo a=$a, b=${!b}, c=$c, d=$d; done < input -
不会是
eval echo ....吗?祝你好运。