Re: Looping counter script ---- newbie question
From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 01/30/05
- Next message: Janis Papanagnou: "Re: select line from file, and then the next line a week later"
- Previous message: masood.iqbal_at_lycos.com: "Looping counter script ---- newbie question"
- In reply to: masood.iqbal_at_lycos.com: "Looping counter script ---- newbie question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Jan 2005 09:11:16 -0500
In article <1107092485.308080.177190@f14g2000cwb.googlegroups.com>,
masood.iqbal@lycos.com wrote:
> First of all my apologies for posting such a simple question. But I am
> new to scripting, so I may be excused.
>
> I have written a small script (by looking at my book) but I have
> obiously made some mistake since it does not run as expected. Any help
> will be appreciated.
Get rid of the spaces around the "=" in your variable assignments. You
got it right inside the while loop, but wrong everywhere else.
>
> Masood
>
> ###################################################
> #!/bin/ksh
>
> if [ "$#" -lt "2" ]
> then
> echo "Needs at least 2 command line arguments"
> exit 1
> fi
>
> begin = $1
> end = $2
>
> if [ "$2" -lt "$1" ]
> then
> echo "Second argument should not be less than first"
> exit 2
> fi
>
> val = $begin
>
> while [ $val -le $end ]
> do
> echo $val
> val=`expr $val + 1`
> done
>
> exit 0
-- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***
- Next message: Janis Papanagnou: "Re: select line from file, and then the next line a week later"
- Previous message: masood.iqbal_at_lycos.com: "Looping counter script ---- newbie question"
- In reply to: masood.iqbal_at_lycos.com: "Looping counter script ---- newbie question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|