Created
September 16, 2020 04:27
-
-
Save pocco81/4cbe2a1c606a583f7f3660f7e5c6ff73 to your computer and use it in GitHub Desktop.
This will check if the folder exists, and then create it if false
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file_1=test_1; if [ -d "$file_1" ]; then echo -e "\nfile:\t→→\t$file_1\nstatus: exists"; else echo -e "file:\t→→\t$file_1\nstatus: does not exists\n"; read -p "Do you want to create $file_1? (y/n): " u_answer; case $u_answer in y|Y|yes|Yes|YES|YeS|YEs|yeS) echo -e "creating $file_1...\n"; `mkdir $file_1`; case "${?}" in 0) echo -e "\nfile: $file_1\nstatus: created"; ;; *) echo -e "ERROR: something happened\nthis might be caused because you don't have permission to write to this folder\nrun 'cd ..' & 'sudo chmod 775 your_folder'"; ;; esac; ;; n|N|No|nO|n0|N0|no) echo "Glad to help!"; ;; *) echo -e "ERROR: command $u_answer not recognized\nexiting the program..."; ;; esac; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment