1
나는 다음과 같은 간단한 코드에서 오류가 발생하는 이유를 알아 내기 위해 많은 시간을 보냈습니다. 누구든지 해결할 수 있으면 고맙습니다.쉘 스크립트에서 문자열의 배열에 값을 할당하는 방법은 무엇입니까?
i=0
while read line
do
if [[ -z "$line" ]]; then
echo "End of numbers"
break
else
{
echo "$line is not empty"
array[$i] = $line
echo array[$i]
((i += 1))
}
fi
done
출력 :
sss
sss is not empty
command.sh: line 10: array[0]: command not found
array[0]
ss2
ss2 is not empty
command.sh: line 10: array[1]: command not found
array[1]