IF와 함께 사용할 수 있는 5가지 유용한 bash 표현식
1. 특정 bash 명령을 사용할 수 있는지 확인하는 방법:
if command -v CMD &> /dev/null; then echo "it exists"; fi

편집 또는 저장this code on github .
2. 특정 파일이 존재하는지 확인하는 방법:
if [ -f /tmp/file ]; then echo 1; fi

편집 또는 저장this code on github .
3. 특정 디렉토리가 존재하는지 확인하는 방법:
if [ -d /tmp ]; then echo 1; fi

편집 또는 저장this code on github .
4. 변수가 비어 있는지 확인하는 방법
if [ -z "$variable" ]; then echo "\$variable is empty"; fi

편집 또는 저장this code on github .
5. 변수가 비어 있지 않은지 확인하는 방법
if [ ! -z "$variable" ]; then echo "\$variable is not empty"; fi
편집 또는 저장this code on github .
Reference
이 문제에 관하여(IF와 함께 사용할 수 있는 5가지 유용한 bash 표현식), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/nonunicorn/5-useful-bash-expressions-to-use-with-if-5dg4텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)