매개 변수를 허용하는 bash 스크립트를 작성하고 있습니다. 나는 그것을 달성하기 위해 getopts를 사용하고있다.getopts가 작동하지 않습니다 - bash
#!/bin/bash
while getopts ":a" opt; do
case $opt in
a)
echo "-a was triggered!" >&2
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
위의 코드 반환 값은 나에게이 오류입니다.
'etOpts_test.sh: line 4: syntax error near unexpected token `in
'etOpts_test.sh: line 4: ` case $opt in
난 당신이 아마 case "$opt" in
(인용 $opt
를) 원하는 라인 4에
을 그리고 그것은 작동합니다. – pahan