조건문에서 "-d" 옵션을 이용하여 특정 디렉터리가 존재하는지 확인할 수 있습니다.

 

[Code] 

mydir="MyDir"
if [[ -d "$mydir" ]]; then
    echo "Exists"
fi
if [[ ! -d "$mydir" ]]; then
    echo "Not Exists"
fi​

 

 

 

'프로그래밍 > ShellScript' 카테고리의 다른 글

[ IF ] 다중 조건 처리할 때 표현방식  (0) 2023.07.27
[shell script] if  (0) 2019.04.20

+ Recent posts