# While condition in shell script

**URL:** <https://community.unix.com/t/while-condition-in-shell-script/324907>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [February 26, 2013, 3:09pm UTC](https://community.unix.com/t/while-condition-in-shell-script/324907 "2013-02-26T15:09:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtagarra](https://community.unix.com/letter_avatar/rtagarra/32/6_449c533f586939b6e5f246632a46421f.png) [@rtagarra](https://community.unix.com/u/rtagarra)\
**Post date:** [February 26, 2013, 3:09pm UTC](https://community.unix.com/t/while-condition-in-shell-script/324907/1 "2013-02-26T15:09:47Z")

</div>

while ["$driverName" = "" -o `checkFile "$driverName"` = "NOK"]  
do  
if ["$driverName" = ""];then  
read driverName  
else  
driverName=""  
fi  
done

can anyone please explain what exactly is happening on 1st line...is it like the conditions being ORed...I have no clue about this.

---

<div class="post-metadata">

**Author:** ![Yoda](https://community.unix.com/user_avatar/community.unix.com/yoda/32/2498_2.png) [@Yoda](https://community.unix.com/u/Yoda)\
**Post date:** [February 26, 2013, 3:28pm UTC](https://community.unix.com/t/while-condition-in-shell-script/324907/2 "2013-02-26T15:28:48Z")

</div>

You are right.

Boolean operator: `-o` is logical OR. If one of the operands is true then condition would be true.

There are other Boolean operators:

`-a` for logical AND and `!` for logical negation.

---

<div class="post-metadata">

**Author:** ![rtagarra](https://community.unix.com/letter_avatar/rtagarra/32/6_449c533f586939b6e5f246632a46421f.png) [@rtagarra](https://community.unix.com/u/rtagarra)\
**Post date:** [February 26, 2013, 3:35pm UTC](https://community.unix.com/t/while-condition-in-shell-script/324907/3 "2013-02-26T15:35:05Z")

</div>

Thanks for confirming...could you be kind enough to tell me what the condition is doing...i have no idea about shell script...i just need to understand this script..that is the problem

while ["$driverName" = "" -o `checkFile "$driverName"` = "NOK"]

i think driverName variable is null OR then i could not understand wht is tht checkfile and NOK...Could you pls help

---

<div class="post-metadata">

**Author:** ![Yoda](https://community.unix.com/user_avatar/community.unix.com/yoda/32/2498_2.png) [@Yoda](https://community.unix.com/u/Yoda)\
**Post date:** [February 26, 2013, 3:42pm UTC](https://community.unix.com/t/while-condition-in-shell-script/324907/4 "2013-02-26T15:42:22Z")

</div>

First operand is checking if string value: `$driverName` is equal to NULL `""`

Second operand appears to be calling a function: `checkFile` by passing string value: `$driverName` as argument and checking if the return value is equal to `"NOK"`

---

<div class="post-metadata">

**Author:** ![rtagarra](https://community.unix.com/letter_avatar/rtagarra/32/6_449c533f586939b6e5f246632a46421f.png) [@rtagarra](https://community.unix.com/u/rtagarra)\
**Post date:** [February 26, 2013, 3:47pm UTC](https://community.unix.com/t/while-condition-in-shell-script/324907/5 "2013-02-26T15:47:36Z")

</div>

You are spot on brother...yes there is a function checkFile...Really thanks for the quick help....
