For Techs.... Techniques.... Technologies....


How to create folder if not exists in Linux

As everybody knows, we can create folders in Linux shell using the command "mkdir".

But this command will throws an error if the folder is existing. So if this command is used in a scripts, it will stops running with error in such situations.

mkdir: cannot create directory : File exists

There is an easy way to resolve this problem.

We can use the option "-p" along with "mkdir" command so that it will not produce any errors if the folder is existing. Also it will create the folder if its not existing.

So the shell scripts will work without any issues.

That's all…

Leave a Reply