I often use this directly in a shell to test an outcome for scripting, and it works fine:
$ if [ -d mydirectory ] ; then echo YES ; fi YES
However, if I want to use the negation using exclamation mark, it fails (well, not really fails, but goes into multiline mode waiting for keyboard input, and I have to escape using Ctrl-C):
$ if [ ! -d makehuman ] ; then echo YES ; if > > ^C $ if [ \! -d makehuman ] ; then echo YES ; if > > ^C
How can I use the negation exclamation mark directly in a shell?