How can we check weather the directory is created or not in shell script???
i mean if i write
mkdir dirname
and if i have to run the script continuously
is there a way to check weather the directory exists or not???
can we do that?
How can we check weather the directory is created or not in shell script???
i mean if i write
mkdir dirname
and if i have to run the script continuously
is there a way to check weather the directory exists or not???
can we do that?
You can either check the exit status of the mkdir command directly
or by using the built-in exit status variable $?Code:mkdir "$dir" || do something
or test the directory existence with the -d file testCode:mkdir "$dir" if [ $? -ne 0 ]; then ...
Just some ideasCode:if [ -d "$dir" ]; then ...
Bookmarks