qlqhqo2341 / qlqhqo2341.github.io

홈피
https://qlqhqo2341.github.io/
0 stars 0 forks source link

쉘스크립트 if문 정리 #11

Open qlqhqo2341 opened 3 years ago

qlqhqo2341 commented 3 years ago

상황

세부 내용

내장변수 - 커맨드 / 인자값

내장변수 - 기타

문자열 비교 if else

if [ $1 == 'start' ]
then
  echo 'this is start';
fi

숫자 비교 if else

if [[ $# -ne 1 ]]
then
  echo 'there is not correct usage';
else
elif [[ $# -eq 2 ]]
then 
  echo 'argument is 2';
then
  echo 'correct!';
fi

분명히 다르다, 브라켓 갯수도 다르고, 연산자도 다르지 확인하고 쓰자;