[PLUG] How to test a string against a blank string in shell script

Gaurav Pant gauravggs at gmail.com
Thu Mar 25 22:09:20 IST 2010


Hi

On Thu, Mar 25, 2010 at 5:43 PM, Shreerang Patwardhan
<patwardhan.shreerang at gmail.com> wrote:
> Hey all,
>     I found the solution to my problem which was as stated below:
>
>    How do we compare a string with a blank string.
> Example: String 1 = test
>                String 2 =

to test for a blank string in shell scripting use
-z string  returns True if the length of string is zero.
 -n string True if the length of string is non-zero.

if you want to consider a string containing all spaces check it with grep!!!

regards
Dexter




More information about the Plug-mail mailing list