I am trying to determine if there is a file or directory. I tried the following commands to see if the file exists and they work correctly:
if [ -a 'settings.py' ]; then echo 'exists'; fi
exists
if [ -a 'foo' ]; then echo 'exists'; fi
But when I try this:
if [ ! -a 'settings.py' ]; then echo 'does not exist'; fi
does not exist
if [ ! -a 'foo' ]; then echo 'does not exist'; fi
does not exist
'does not exist' is displayed no matter what.
source
share