Consider the following in bash:root@debian-lap:/tmp I=$(echo)root@debian-lap:/tmp echo $Iroot@debian-lap:/tmp [ -z $I ] && echo TRUE || echo FALSETRUEThis means that variable $I is zero. The same I could achieve with negation test to see if variable is non zero, and ! makes test reverse so it checks is variable zero root@debian-lap:/tmp ! [ -n $I ] && echo TRUE || echo FALSETRUEroot@debian-lap:/tmpSo, my question is, are there any special cases when to use -z and ! -n , or vice versa ! -z and -n as they are basically doing the same test? Thanks
Usage of -n and -z in test built in - Bash
bash;shell script;shell;test
You are given -n and -z for the same reason that other test suites give you both == and !=, or AND and NOT.  Some test cases can be made a lot clearer to future maintainers by eschewing double-negatives.  Also, as mentioned in an above comment, ancient incarnations of sh (i. e. the Bourne and Thompson shells), as opposed to modern POSIX sh did not have a ! keyword to negate the truthiness of test expressions.