Re: [Nolug] Bash question

From: Katrina Niolet <kniolet_at_ildiinc.com>
Date: Fri, 20 Apr 2007 18:40:39 +0000
Message-ID: <2079716223-1177094423-cardhu_blackberry.rim.net-1666259942-@bxe044-cell01.bisx.prod.on.blackberry>

"*cough* ... Perl .. *cough"
LOL

Yep Perl is definately handy for shell-type scripting.

--sent from my BlackBerry 8100--
Katrina Niolet
kniolet@ildiinc.com

  

-----Original Message-----
From: "B. Estrade" <estrabd@gmail.com>
Date: Fri, 20 Apr 2007 17:58:39
To:nolug@nolug.org
Subject: Re: [Nolug] Bash question

The only thing I could get to do what you want is:

#!/bin/sh

VAR="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"

CONNECT=0

 for i in $VAR; do
   ((CONNECT++))
   if [ $i == $1 ]; then
     break
   fi
 done

echo $CONNECT

BTW, I would not use a construct like this in a shell script even if
it is possible. I didn't realize that this was possible in bash, but
it is. I tried various ways to expand the value such that it did the
implied enumeration, but I could not get it to work. If you tell us
what you are actually trying to do, I am sure someone would be able to
give you a better way (and language..*cough* ... Perl .. *cough) in
which to do this sort of thing.

Cheers,
Brett

On 4/20/07, David John <djohn@archdiocese-no.org> wrote:
>
>
>
>
> Hello list,
>
>
>
> In a Bash script, I have something like so:
>
>
>
> VAR="$1"
>
> CONNECT=0
>
> for i in {A..$VAR}
>
> do
>
> ((CONNECT++))
>
> done
>
>
>
> I call the script like so:
>
> ./script.sh C
>
>
>
> The above spits out 1 regardless of what letter I use.
>
> My question is, how do I use a variable inside of a brace expansion?
>
> If I simply did "for I in {A..C} …etc" $CONNECT would equal 3.
>
>
>
> Thanks.
>
>
>
> Dave This message has been scanned by the Internet Service Departments
> Virus/Spam filter.
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 269.5.5/769 - Release Date: 4/19/2007
> 5:56 PM
>


--
225.578.1920
AIM: bz743
http://www.loni.org/
estrabd@lsu.edu
estrabd@gmail.com
___________________
Nolug mailing list
nolug@nolug.org
6‰n‚f¢–)à–+-ž‰n‚z%º
+
Received on 04/20/07

This archive was generated by hypermail 2.2.0 : 12/19/08 EST