if statement
sam
srf10130 at vtc.vsc.edu
Thu Aug 20 16:48:34 UTC 2009
Ray Parrish wrote:
> Hello,
>
> I am having difficulty with an if statement. Here it is -
>
> # load the sleep interval in seconds from the command line.
> interval=$2;
> # if specified interval in seconds is less than 200 or empty, set it
> to the default of 300 seconds
> if [ $interval == "" ]
>
> then
> interval=300; # five minutes default setting
> echo "interval blank";
> fi
>
> Here is the error I keep getting, no matter how I try to change the if
> statement around -
>
> ray at RaysComputer:~$ ~/WebChange/UpdateWebURL.sh
> http://finance.yahoo.com/q?s=MSFT
> /home/ray/WebChange/UpdateWebURL.sh: line 25: [: ==: unary operator expected
>
> I actually want to check to see if interval is blank or less than 200,
> but I can't seem to get that to work.
>
> This happens with a single "=" as well. What am I doing wrong here?
>
> Thanks for any help you can be. Later, Ray Parrish
>
the use of square brackets (if [...]) uses linux command test to provide
the boolean value.
try man test for starters
sam
More information about the ubuntu-users
mailing list