Test for non-zero length string in Bash: [ -n “$var” ] or [ “$var” ]

I’ve seen Bash scripts test for a non-zero length string in two different ways. Most scripts use the -n option: #!/bin/bash # With the -n option if [ -n “$var” ]; then # Do something when var is non-zero length fi But the -n option isn’t really needed: # Without the -n option if [ … Read more