location.txt에서 디렉토리 위치를 추출하여 배열에 저장하려고하는데 모양이 좋지 않습니다. 내가 스크립트를 실행하면, 배열에 텍스트 줄을 저장하는 중 오류가 발생했습니다.
난이 오류가 여기에./test.sh: line 7: location.txt: No such file or directory [email protected] $ ./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
이에게 할 수있는 몇 가지 하나를 얻을 내가 뭘 잘못했는지 말해 줄래? 내가 방금 할당 할 때문에
AIX에서 'bash'또는 '/ bin/sh'가 무엇이든 실제로 사용 하시겠습니까? –
당신의 오류는'echo $ {Unix_Array [$ i]}'대신'echo $ (Unix_Array [$ i])'에서 나온 것입니다. –