본문 바로가기

Tech/Linux

Bash - if 구문

네이버 공유하기
728x90


Bash - if 구문 


  1. #!/bin/bash
  2. # else example
  3. if [ $# -eq 1 ]
  4. then
  5. nl $1
  6. else
  7. nl /dev/stdin
  8. fi
OperatorDescription
! EXPRESSIONThe EXPRESSION is false.
-n STRINGThe length of STRING is greater than zero.
-z STRINGThe lengh of STRING is zero (ie it is empty).
STRING1 = STRING2STRING1 is equal to STRING2
STRING1 != STRING2STRING1 is not equal to STRING2
INTEGER1 -eq INTEGER2INTEGER1 is numerically equal to INTEGER2
INTEGER1 -gt INTEGER2INTEGER1 is numerically greater than INTEGER2
INTEGER1 -lt INTEGER2INTEGER1 is numerically less than INTEGER2
-d FILEFILE exists and is a directory.
-e FILEFILE exists.
-r FILEFILE exists and the read permission is granted.
-s FILEFILE exists and it's size is greater than zero (ie. it is not empty).
-w FILEFILE exists and the write permission is granted.
-x FILEFILE exists and the execute permission is granted.


반응형
네이버 공유하기


* 쿠팡 파트너스 활동을 통해 일정액의 수수료를 제공받을 수 있습니다.