You can use mkdir -p option to create a new directory if does not already exist.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
## Create a new directory mkdir mydir1 ## Try to create a new directory with same name mkdir mydir1 ## mkdir: cannot create directory ‘mydir1’: File exists ## With -p option mkdir -p mydir1 ## no error reported ## you can also create chain of directory at once using -p option mkdir -p mydir1/mydir2/mydir3 rm -r mydir1 |