arrays in C shell

hi guys,
i have the following code in C shell..

set i=0 
while ($i < 11)
master_array=${ARRAY}
i++
done

it gives me error at line 3: Variable syntax.
what is wrong here? any help is appreciated.

Consider not using the C shell, or read about lists on the C shell man page

Try this to see why you should find another shell -
Csh Programming Considered Harmful

i wish i could but i don't have a choice.. any links which explain arrays in detail?

Hi.

Here is a demo script:

#!/usr/bin/env tcsh

# @(#) s1       Demonstrate setting array variable in csh.

echo
echo "(Versions displayed with local utility version)"
sh -c "version >/dev/null 2>&1" && version "=o" tcsh
echo

set ARRAY = ( a b c d e f)
echo ARRAY is $ARRAY

set master_array =
set i = 0

# Copy first 3 items only.

while ( $i < 4 )
# master_array = $ARRAY
set master_array = ( $master_array $ARRAY[$i] )
@ i++
end
# done

echo
echo master_array is $master_array

echo
echo " Easier transfer:"
set first = 2
set last  = 4
set ar = ( $ARRAY[$first-$last] )
echo ar is $ar

exit 0

Producing:

% ./s1

(Versions displayed with local utility version)
Linux 2.6.11-x1
tcsh 6.13.00

ARRAY is a b c d e f

master_array is a b c

 Easier transfer:
ar is b c d

Look over Csh - the C Shell , Google for tutorial csh scripting yields about 250K hits. See also man csh ... cheers, drl

PS Standard advice: avoid scripting in csh family; use Bourne shell family whenever possible.

thanks that helped a lot..

how do i convert this bash statement in c shell?

result=`expr $c \> $d`