我正在尝试从 location.txt 中提取目录位置并将其保存到一个数组中,但它看起来并不好。当我执行脚本时,
我得到这个错误
./test.sh: line 7: location.txt: No such file or directory bina@ajax $ ./test.sh
./test.sh: line 5: =/apps/IBM: No such file or directory
./test.sh: line 5: =/usr/home: No such file or directory
./test.sh: line 11: Unix_Array[0]: command not found
./test.sh: line 11: Unix_Array[1]: command not found
这是我的代码
#!/bin/sh
counter=0
while read -r line; do
${Unix_Array[${counter}]}=$line;
let counter=counter+1;
done < location.txt
for ((i=0 ;counter > i; i++))
do
echo $(Unix_Array[$i])
done
和文本文件 location.txt
/apps/IBM
/usr/home
/var/login
有人可以告诉我我做错了什么吗?我可能犯了一个我不知道的愚蠢错误……(我是 UNIX 的新手)
提前致谢