I'm trying to determine if a file or directory doesn't exist. I tried the following commands to see if a file does exist and they work correctly:
if [ -a 'settings.py' ]; then echo 'exists'; fi
exists #output
if [ -a 'foo' ]; then echo 'exists'; fi #outputs nothing
But when I try this:
if [ ! -a 'settings.py' ]; then echo 'does not exist'; fi
does not exist #shouldn't be output since the file does exist
if [ ! -a 'foo' ]; then echo 'does not exist'; fi
does not exist
'does not exist' is output no matter what.