You can use the "mkdir" command with the "-p" flag to create a directory only if it does not already exist. The "-p" flag creates any necessary parent directories if they do not exist.
Here's the basic syntax:
mkdir -p /path/to/directory
If the directory already exists, the command will do nothing. If it does not exist, the command will create the directory and any necessary parent directories.
For example, if you want to create a directory called "mydir" in your home directory, you can use the following command:
mkdir -p ~/mydir
This will create the "mydir" directory in your home directory if it does not already exist. If it already exists, the command will do nothing.
Comments (0)