if statement
Ulf Rompe
ulf.buntu at rompe.org
Fri Aug 21 12:50:08 UTC 2009
Am Donnerstag, den 20.08.2009, 13:44 -0700 schrieb Ray Parrish:
> >> to the default of 300 seconds
> >> if [ $interval == "" ]
> >>
> >> then
> >
> > Shouldn't this statement be something like :
> >
> > If [ $interval == "" ] ; then
> >
> > Aren't you missing the semi-colon here ?
> >
> It works fine without the semi-colon, does it need to be there for
> some other reason?
You can separate statements with either linefeeds or semicolons. Thus
this:
if true
then
echo "it is true"
fi
is the same as this:
if true; then
echo "it is true"
fi
or even this:
if true; then echo "it is true"; fi
Since "then" is a required statement on its own (but looks ugly and
doesn't deserve an own line), it is common practice to combine "if" and
"then" on a single line, in which case you need the semicolon.
[x] ulf
--
One of the main causes of the fall of the roman empire was that, lacking zero,
they had no way to indicate successful termination of their C programs.
More information about the ubuntu-users
mailing list