"Syntax error: unexpected "(""의 두 판 사이의 차이

(새 문서: ==개요== ;<nowiki>syntax error: unexpected "("</nowiki> <source lang='console'> # cat a.sh ARR=("John Smith" "Jane Doe" "Mike Barnes" "Kevin Patterson") for VALUE in "${ARR[@]}"; d...)
 
12번째 줄: 12번째 줄:
# sh a.sh
# sh a.sh
a.sh: line 1: syntax error: unexpected "("
a.sh: line 1: syntax error: unexpected "("
</source>
----
<source lang='console'>
# cat a.sh
set -- "John Smith" "Jane Doe" "Mike Barnes" "Kevin Patterson"
while [ $# -gt 0 ]; do
        echo [$1]
        shift;
done
</source>
<source lang='console'>
# sh a.sh
[John Smith]
[Jane Doe]
[Mike Barnes]
[Kevin Patterson]
</source>
</source>


==같이 보기==
==같이 보기==
* [[sh foreach]]
* [[bash foreach]]
* [[bash foreach]]


==참고==
==참고==
* https://www.unix.com/shell-programming-and-scripting/119925-array-sh.html
* https://unix.stackexchange.com/questions/45781/shell-script-fails-syntax-error-unexpected
* https://unix.stackexchange.com/questions/45781/shell-script-fails-syntax-error-unexpected


[[분류: sh]]
[[분류: sh]]

2020년 5월 21일 (목) 15:15 판

1 개요

syntax error: unexpected "("
# cat a.sh
ARR=("John Smith" "Jane Doe" "Mike Barnes" "Kevin Patterson")
for VALUE in "${ARR[@]}"; do
        echo "[$VALUE]"
done
# sh a.sh
a.sh: line 1: syntax error: unexpected "("

# cat a.sh
set -- "John Smith" "Jane Doe" "Mike Barnes" "Kevin Patterson"
while [ $# -gt 0 ]; do
        echo [$1]
        shift;
done
# sh a.sh
[John Smith]
[Jane Doe]
[Mike Barnes]
[Kevin Patterson]

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}