Scott Klement wrote:
That code doesn't do what you think it does!!
if [ -z "$1" ] ; then
echo 'No!'
else
echo 'Yes!'
fi
Yep. I'm suitably chastised. Now I had to look it up. [ -z "$1" ] is
true if $1 has a zero length. [ -n "$1" ] is true if $1 has a non-zero
length in Bourne shells. There are also a whole bunch of other switches,
mostly related to file system tests:
-b = true of file exists and is a block special file
-c = true if file exists ans is a character special file
-d = true if pathname exists and is a directory
-e = true if the file or directory specified exists
-f = true if the file exists and is a regular file
-g = true if the file or directory exists and has its SGID bit set
-h = true if file exists and is a symbolic link
-k = true if file or directory specified exists and had its "sticky" bit
set.
-p = true if file exists and is a named pipe
-r = true if the file or directory specified exists and is readable
-s = true if file exists and has a size greater than zero
-u = true if the file or directory exists and has its SUID bit set
-w = true if the file or directory specified exists and is writable
-x = true if the file or directory exists and is executable
-O = true if the file or directory exists and is owned by the effective
user ID of the current process.
Gotta love this stuff!