Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why does the non-zero and the zero operator both return true in the shell script? This makes no sense. Please see the following small

 image text in transcribed  

Why does the non-zero and the zero operator both return true in the shell script? This makes no sense. Please see the following small script I have written. I set a variable 'zero' to have nothing. I also get the same results if I set 'zero' to "" or zero="" zero= #the below code prints "is not length zero" if [ -n $zero ] ; then echo "$zero is not length zero" ; fi #the below code prints if [ -z $zero ]; then " is length 0" echo "$zero is length 0"; fi

Step by Step Solution

3.49 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Chemistry A Molecular Approach

Authors: Nivaldo Tro

5th Edition

0134874374, 978-0134874371

More Books

Students also viewed these Programming questions

Question

Explain why psychologists sometimes use animals in their research.

Answered: 1 week ago