To check if a directory exist or not use following script:
#!/bin/bash FILE_NAME=$1 if [ -f $FILE ]; then echo "File $FILE_NAME exists" else echo "File $FILE_NAME does not exists" fi
You can also use following one liner to do same validation:
$ [ -d /usr/share ] && echo "Directory exists" || echo "Directory does not exists"
-Sany
Reblogged this on Gigable – Tech Blog.