我试图将 'f-$count'(f-1,f-2) 名称放入数组中。
下面是代码,
echo "Enter the count"
read count
echo $count
#arr=()
i=1
while true;
do
if ["$i" -gt "$count"]; then
exit 0
else
arr[$i]=f-$i
i=$((i+1))
fi
done
echo ${arr[@]}
我收到的错误为 'script.sh: line 11: [3570: command not found
’不断地。
在 shell 编程中,括号中的if
必须用空格分隔:
if ["$i" -gt "$count"]; then
MUST be:
if [ "$i" -gt "$count" ]; then
[EDIT]左括号 ([
) 实际上是一个内置的 shell 命令,因此与任何命令一样,后面需要空格将其与其参数分隔开。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)