"Bash if"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 8개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;Bash if
;Bash if
<source lang='bash'>
{{소스헤더|Syntax}}
<syntaxhighlight lang='bash'>
if [조건]; then
# if 블럭
else
# else 블럭
fi
</syntaxhighlight>
 
==예시==
<syntaxhighlight lang='bash'>
He="John Smith"
He="John Smith"
if [ "$He" = "John Smith" ]; then
if [ "$He" = "John Smith" ]; then
9번째 줄: 19번째 줄:
fi
fi
# He is John Smith
# He is John Smith
</source>
</syntaxhighlight>
<syntaxhighlight lang='bash'>
He="Jane Doe"
if [ "$He" != "John Smith" ]; then
echo "He is not John Smith"
fi
# He is not John Smith
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[Bash switch]]
{{z컬럼3|
* [[if]]
* [[Bash if true/false]]
* [[Bash case]]
* [[Bash 숫자 비교]]
* [[Bash 숫자 비교]]
* [[if]]
* [[Bash if - 첫번째 인자가 foo인지 아닌지에 따라 분기]]
* [[쉘 프로그래밍 제어문]]
}}


[[분류: Bash]]
[[분류: Bash]]

2024년 4월 4일 (목) 14:43 기준 최신판

1 개요[ | ]

Bash if
Syntax
if [조건]; then
	# if 블럭
else
	# else 블럭
fi

2 예시[ | ]

He="John Smith"
if [ "$He" = "John Smith" ]; then
	echo "He is John Smith"
else
	echo "He is not John Smith"
fi
# He is John Smith
He="Jane Doe"
if [ "$He" != "John Smith" ]; then
	echo "He is not John Smith"
fi
# He is not John Smith

3 같이 보기[ | ]

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