Web Programming

리눅스 파일 존재 여부 확인 명령어

junha6316 2022. 12. 6. 13:07
f test -f './test_file.sh'; then
  echo "File Exist !!!";
fi

// test 명령어 대신 [], [[]] 기호 사용 가능
if [ -f ./test_file.sh ]; then
  echo "File Exist !!!";
fi

// 파일 없을 때
if [ ! -f ./test_file.sh ]; then
  echo "Not Exists";
fi

// 디렉토리 존재 여부
if [ -d ./abc ]; then
  echo "Directory Found !!!";
fi