"Bash if - 첫번째 인수가 foo인지 아닌지에 따라 분기"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
==개요==
==개요==
;Bash if - 첫번째 arg가 hello인지 아닌지에 따라 분기
;Bash if - 첫번째 arg가 foo인지 아닌지에 따라 분기
;Bash if - 첫번째 인자가 hello인지 아닌지에 따라 분기
;Bash if - 첫번째 인자가 foo인지 아닌지에 따라 분기


<syntaxhighlight lang='console'>
<syntaxhighlight lang='console'>
if [[ "$1" == "hello" ]]; then
if [[ "$1" == "foo" ]]; then
   # 첫번째 인수가 "hello"인 경우
   # 첫번째 인수가 "foo"인 경우
else
else
   # 첫번째 인수가 "hello"가 아닌 경우
   # 첫번째 인수가 "foo"가 아닌 경우
fi
fi
</syntaxhighlight>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2024년 4월 4일 (목) 14:43 판

1 개요

Bash if - 첫번째 arg가 foo인지 아닌지에 따라 분기
Bash if - 첫번째 인자가 foo인지 아닌지에 따라 분기
if [[ "$1" == "foo" ]]; then
  # 첫번째 인수가 "foo"인 경우
else
  # 첫번째 인수가 "foo"가 아닌 경우
fi

2 같이 보기

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