You can use test -d (see man test). -d file True if file exists and is a directory. For example: test -d "/etc" && echo Exists || echo Does not exist