Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

test -z command 2

Status
Not open for further replies.

goldenradium2001

Technical User
Mar 22, 2002
91
US
I have a file called hello with nothing in it. I created it using the following command:

# touch hello

When I do in the C shell:

# test -z hello
# echo $status

I get a nonzero status of 1. I thought that the -z was used to test if the hello file had anything in it. The definition I've always seen was that the -z means to test if the file is zero length. There is nothing in the hello file. So why does it give me a 1 exit status?

Please help!

Thanks in advance.
 
Goldenradium:

I'm not csh expert, but I believe the test -z works only on checking whether shell variables are null. At least, that's the only way it works on Solaris 7. I'd check your man page on test.

Regards,

Ed
 
Golden:

I think you want test -s - filename has a size greater than 0.

Ed
 
-z is for string-length
olded's answers is correct. -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top