프로그래밍 [Programming]/Bash shell script

특정 파일의 존재 유무에 따라 실행하는 if 문

Ani Gil 2021. 9. 25. 13:41
#!/bin/bash

FILE_NAME='ls Dockerfile'

if [ $FILE_NAME = "Dockerfile" ]
then
    echo $FILE_NAME
else
    echo "This is not found Dockerfile"
fi

위 Bash shell script는 스크립트가 실행되는 디렉토리에서 Dockerfile의 유무를 확인하는 Bash shell script이다.

조건문에 기재된 echo를 특정 명령어로 치환하여서 사용할 수 있다.