osx - shell script - creating folder structure -
i wrote little shell script(test.sh) create basic folder structure:
#!/bin/bash # check if directory exists, # if doesnt, create one. if [ ! -d "~/.dir1" ]; mkdir ".dir1" else rm -rf ".dir1" mkdir ".dir1" fi
when run
test.sh
in console, hidden folder created.
but: when run again tells me:
mkdir: .dir1: file exists
but exist because removed in shell script before created new one! why display message?
thanks , greetings!
replace
[ ! -d "~/.dir1" ]
by
[ ! -d "${home}/.dir1" ]
Comments
Post a Comment