[[+content_image]]
V
V
VS2019-10-04 13:37:42
bash
VS, 2019-10-04 13:37:42

What do these options mean in a BASH script?

There is the following script:

!/bin/bash

set -e

echo "Application backuping... "

BACKUPS_ROOT=/var/www/homework/backups/restore-backup_$(date '+%d-%m-%Y').sh

if [[ ! -d $BACKUPS_ROOT ]];
then
   echo "Creating backup directory..."
   mkdir -p "$BACKUPS_ROOT"
fi

# TODO: make database dump
touch dump.sql

gzip --best dump.sql
mv dump.sql.gz "$BACKUPS_ROOT"

zip -9 -qj uploads.zip backend/web/uploads/*
mv uploads.zip "$BACKUPS_ROOT"

echo "Backup is ready!"

Question:
What does the -d flag mean, on the 9th line:
if [[ ! -d $BACKUPS_ROOT ]];

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
P
pfg21, 2019-10-04
@defect00

option to check if the directory exists.
:) here the command name is [

$ man [
*****
       -d FILE
              FILE exists and is a directory
****

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question