Skip to content

Instantly share code, notes, and snippets.

@maxcnunes
Created May 23, 2014 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxcnunes/8f824801cf9d29982c60 to your computer and use it in GitHub Desktop.
Save maxcnunes/8f824801cf9d29982c60 to your computer and use it in GitHub Desktop.
# inline
[ -d "my_dir" ] && echo "Yes" || echo "No"
[ -f "my_file" ] && echo "Yes" || echo "No"
# function
dir_exists() {
( test -d $1 > /dev/null 2>&1 ) && return 0 || return 1
}
file_exists() {
( test -d $1 > /dev/null 2>&1 ) && return 0 || return 1
}
if !(dir_exists "my_dir") then
echo "Not"
fi
if !(file_exists "my_file") then
echo "Not"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment