I have written a bash script to create a folder if it doesn't already exist and have set the variables in my environment file and referenced that in my .sh file
Below is my script I have added the variables in the .sh file which I have added in my environment file.
#!/bin/bash
if [ ! -d "$checkfolder" ]; then
mkdir -p "$createfolder";
fi
I have set the following environment variables in my /etc/environment file
checkfolder=/home/ubuntu/hello23
createfolder=/home/ubuntu/hello23
when I execute the script I am getting the following errors:
ubuntu@:~/cicd$ ./createfolder.sh
mkdir: cannot create directory ‘’: No such file or directory
Here is the normal script I have written, which works and creates a folder if it does not exist
if [ ! -d /home/ubuntu/hello ]; then
mkdir -p /home/ubuntu/hello;
fi
What is the issue here and what changes should i make?