bash Scripts

Jay plug-discuss@lists.plug.phoenix.az.us
Thu, 23 May 2002 21:05:16 -0700 (MST)


On Wed, 22 May 2002, Clayton Stapleton wrote:

> #!/bin/bash
> for i in `seq 1 10`;


Try removing the ";" on this one. You already have a CRLF because the "do"
statement is on another line.


> With the "while" and "until" scripts when they are run I get a ">" and it
> just sets there until I do a ctrl-c. The scripts are as follows:
>
> #!/bin/bash
> COUNTER=0
> while [  $COUNTER -lt 10 ]; do
>     echo The counter is $COUNTER
>     let COUNTER=COUNTER+1
> done


There are a few errors in this one. Here is an example that works:

COUNTER=0
while [ $COUNTER -lt 10 ]
do
	echo "COUNTER $COUNTER"
	let COUNTER=$COUNTER+1
done


> #!/bin/bash
>          COUNTER=20
>          until [  $COUNTER -lt 10 ]; do
>              echo COUNTER $COUNTER
>              let COUNTER-=1
>          done


Same here. This one works:

COUNTER=20
until [ $COUNTER -lt 10 ]
do
	echo "COUNTER $COUNTER"
	let COUNTER=$COUNTER-1
done


~Jay



> I am running these scripts in my home directory.
> Any help will be appriciated.
>
> Clay Stapleton
> Scottsdale, Arizona
>
>
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.
>
> PLUG-discuss mailing list  -  PLUG-discuss@lists.plug.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>

-- 
~Jay