# if [ -d != ~/.ssh/ ] ; then echo mkdir ~/.ssh/ ; fi mkdir /root/.ssh/ # ls -ld ~/.ssh/ drwxr-xr-x 2 root root 4096 Jan 5 12:19 /root/.ssh/ # how come this doesn't work?
Looks like '[' and 'test' are not similar: Use: Code: if test ! -d ~/.ssh/ ; then echo mkdir ~/.ssh/ ; fi -d check if a directory exists. You cannot do '-d !='
'test' is the equivalent command for '['. In this case it replaces the []. Do Code: man test on your server and you'll see all the options.