반응형
If
-
shell script 작성법 - if문 사용법 (기본 사용법)프로그래밍/Linux 2018. 11. 12. 11:02
기본 사용법 if [ 조건식 ]; then // if문 시작 ~elif ~else ~fi 또는 if [ 조건식 ]then // if문 시작 ~elif ~else ~fi // if문 종료 if 와 [ 사이는 반드시 한 칸을 띄어써야 한다. 조건식에 들어가는 조건은 &&(and) 나 ||(or) 로 연결하여 사용 가능하다 다양한 조건을 연결하여 사용하는 예시 if [ $is_sorted_file -eq 0 ] && [ $today_cnt -gt 0 ] && [ $today_cnt_sorted -eq 0 ]; then echo "there is new today news:"$entry elif [ $is_sorted_file -gt 0 ]; then echo "this file is sorted file:"$..