Prompt pliz script in Linux, which would do the following:
- Check if folder exists
- If yes, then do nothing.
- If not, create this folder.
Prompt pliz script in Linux, which would do the following:
In the bash script (mkdir.sh) you can do this:
DIR=$1 if [ ! -d "$DIR" ]; then # Создать папку, только если ее не было mkdir $DIR fi
Run as
$ ./mkdir.sh
You can also check if the name is not a symbolic link:
DIR=$1 if [[ ! -d "$DIR" && ! -L "$DIR" ]] ; then # Создать папку, только если ее не было и не было символической ссылки mkdir $DIR fi
mkdir <name> 2> /dev/null
mkdir -p
It will create subdirectories if necessary (mkdir -pa / b / c), and in the meantime it will not react to the already created directory.
Source: https://ru.stackoverflow.com/questions/2748/
All Articles