04-27-07 12:17 AM
On 2007-04-26, lazyboy_2k@yahoo.com wrote:
> Hi,
>
> I'm looking at a internal script & see this below if statement but I
> don't understand it. Could someone please explain what it means if
> you don't mind?
The script is broken.
> #!/bin/ksh
>
> row=0
> if [ $row > 0 ]
That should be:
if [ $row -gt 0 ]
In the shell, '>' is the redirection operator, not a comparison
operator, although some shells allow it as a string comparison
operator if it is escaped, e.g.:
if [ "$q" \> alpha ]
> then
> : # note I don't understand what " : " notation actually does &
means
It is a command that does nothing. Any arguments will be expanded,
$_ will be set, and any side effects will be performed:
q=
: ${q:=qwerty} asdfg
printf "%s\n" "$q" "$_"
> else
> ........
> fi
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
[ Post a follow-up to this message ]
|