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!


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.