[Shell script/cmd] script comparisons (스크립트 비교 구문)
반응형
* script comparisons
| String Comparison | Description |
| Str1 = Str2 | Returns true if the strings are equal |
| Str1 != Str2 | Returns true if the strings are not equal |
| -n Str1 | Returns true if the string is not null |
| -z Str1 | Returns true if the string is null |
| Numeric Comparison | Description |
| expr1 -eq expr2 | Returns true if the expressions are equal |
| expr1 -ne expr2 | Returns true if the expressions are not equal |
| expr1 -gt expr2 | Returns true if expr1 is greater than expr2 |
| expr1 -ge expr2 | Returns true if expr1 is greater than or equal to expr2 |
| expr1 -lt expr2 | Returns true if expr1 is less than expr2 |
| expr1 -le expr2 | Returns true if expr1 is less than or equal to expr2 |
| ! expr1 | Negates the result of the expression |
| File Conditionals | Description |
| -d file | True if the file is a directory |
| -e file | True if the file exists (note that this is not particularly portable, thus -f is generally used) |
| -f file | True if the provided string is a file |
| -g file | True if the group id is set on a file |
| -r file | True if the file is readable |
| -s file | True if the file has a non-zero size |
| -u | True if the user id is set on a file |
| -w | True if the file is writable |
| -x | True if the file is an executable |
반응형
'IT > shell script, cmd' 카테고리의 다른 글
| [Shell script/cmd] ln 심볼릭/symlink 링크 (0) | 2021.07.20 |
|---|---|
| [Shell script/cmd] path 폴더 존재 유무 체크 확인 script (0) | 2021.07.20 |
| [Shell script/cmd] 연속 명령 수행 방법 (; , & , &&) (0) | 2021.07.19 |
| [Shell script/cmd] nohup 동작 유지, background 수행 (0) | 2021.07.19 |
| [Shell script/cmd] 정규식 sh 실행 시 인자, 아규먼트 변수[$1, $0, $*, $#, $@] (0) | 2021.07.19 |