bash입니다.
원본파일이 있습니다.
이 파일을 vi로 편집시 백업을 실행해야 하는데 파일이름.backup 이라는 디렉토리에
저장을 합니다. 이때 폴더가 없으면 만들고 있으면 폴더 생성을 하지 않아야 하는데
어떤 함수와 방식을 사용해야 하는지 도움을 주시면 감사하겠습니다.
- In bash shell
To check if a directory exists in a bash shell script you can use the following:
if [ -d "$DIRECTORY" ]; then # Will enter here if $DIRECTORY exists fi
Or to check if a directory doesn't exist:
if [ ! -d "$DIRECTORY" ]; then # Will enter here if $DIRECTORY doesn't exist fi
- In Cshell
if ( ! -e $DIRECTORY ) then # Will enter here if $DIRECTORY doesn't exist endif
- In bash shell To check if
- In bash shell
To check if a directory exists in a bash shell script you can use the following:
if [ -d "$DIRECTORY" ]; then
# Will enter here if $DIRECTORY exists
fi
Or to check if a directory doesn't exist:
if [ ! -d "$DIRECTORY" ]; then
# Will enter here if $DIRECTORY doesn't exist
fi
- In Cshell
if ( ! -e $DIRECTORY ) then
# Will enter here if $DIRECTORY doesn't exist
endif