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?

$?in myPS1so the prompt always shows the exit status of the last foreground command. This makes testing conditions as easy as running[ -d mydir ]and looking at my current prompt. Another way to test with less typing and w/o using the prompt is[ -d mydir ] && echo yes. – jw013 Aug 6 '11 at 13:09$?- cheers! – sdaau Aug 6 '11 at 13:51