[NTLUG:Discuss] bash shell array question...
Fred James
fredjame at concentric.net
Wed Feb 27 09:12:44 CST 2002
(Sorry - on the first attempt I cut out the discussion part - second try
here)
#! /bin/bash
#
makeList.sh
#
ServerList=$1
WordList=$2
declare -a S
declare -a U
Count=0
cat $ServerList | while read Server User
do
S[$Count]=$Server
U[$Count]=$User
Count=`expr $Count + 1`
echo "$Count"
echo "${#S[*]} ${#S[@]}"
ACount=$Count
done
echo "count : $Count"
echo "number of elements : ${#S[*]} ${#S[@]}"
echo "acount : $ACount"
Leave=0
echo "$Leave $Count"
while test $Leave -lt $Count
do
echo "$Leave: ${S[$Leave]} ${U[$Leave]}"
Leave=`expr $Leave + 1`
done
exit
Victor Brilon wrote:
> Can you post some code showing exactly what you mean? Sounds like
> you're running into a variable scope problem maybe.
>
> Victor
>
> On 26-Feb-2002 Fred James wrote:
>
>>Within a while loop, strings are assigned to the elements of an
>>array,
>>and the index variable is incremented.
>>
>>Once the loop completes, the value of the index variable is zero.
>>
>>What is happening?
>>
>>--
>>...make every program a filter...
>>
>>
>>_______________________________________________
>>http://www.ntlug.org/mailman/listinfo/discuss
>>
>
--
...make every program a filter...
More information about the Discuss
mailing list