Directories

bash: working with directories

Sample code: check if directory exists, if not, create it. Check if the directory is writable.

if test ! -d "$MYDIR"
then
  mkdir "$MYDIR"
elif test ! -w "$MYDIR"
then
  echo "$MYDIR exists but is not writable."
  exit 3
fi

Syndicate content