Create A File In Directory And Create Directory If Doesnt

[Solved] Create A File In Directory And Create Directory If Doesnt | Php - Code Explorer | yomemimo.com
Question : bash create a folder if it doesn't exist

Answered by : clever-cod3

if [[ ! -d "$DIRECTORY" ]]
then mkdir -p "$DIRECTORY" || echo "$(date "+%Y-%m-%d %T") - Fail to create directoty $DIRECTORY"
fi
# Or as one liner
[[ ! -d "$DIRECTORY" ]] && mkdir -p "$DIRECTORY"

Source : https://devconnected.com/how-to-check-if-file-or-directory-exists-in-bash/ | Last Update : Wed, 01 Jun 22

Question : create a file in directory and create directory if doesnt exists bash

Answered by : hesham-hammad

install -Dv /dev/null this_dir/new.txt

Source : https://askubuntu.com/questions/1191626/how-to-create-a-new-file-via-touch-if-it-is-in-a-directory-which-doesnt-exist | Last Update : Tue, 08 Nov 22

Answers related to create a file in directory and create directory if doesnt exists bash

Code Explorer Popular Question For Php