Cshell question: taking wordlists as a single string

BURNS,JIM gt0178a at prism.gatech.EDU
Mon Aug 20 03:17:10 AEST 1990


in article <1990Aug18.141141.24890 at warwick.ac.uk>, cudcv at warwick.ac.uk (Rob McMahon) says:
> I know ksh has `set -A array', but does it have an equivalent of "$@" for
> arrays other than the positional paramters ?  We don't have ksh, and can't
> afford to get it, but when bash gets a bit more solid I will switch to it if
> it has an equivalent of csh's $array:q.

The following script is followed by its corresponding output (note the set
-A is redundant, and its not quite as convenient as in csh, where 'arr=
(one two three) sets $arr[1], $arr[2], and $arr[3] in one fell swoop):

set -x
arr="one two three"
echo $arr
echo ${arr[0]}
echo ${arr[1]}
arr[1]="four five six"
echo ${arr[1]}
echo ${arr[0]}
echo ${arr[*]}
echo ${#arr[*]}

+ arr=one two three
+ echo one two three
one two three
+ echo one two three
one two three
+ echo

+ arr[1]=four five six
+ echo four five six
four five six
+ echo one two three
one two three
+ echo one two three four five six
one two three four five six
+ echo 2
2
-- 
BURNS,JIM
Georgia Institute of Technology, Box 30178, Atlanta Georgia, 30332
uucp:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt0178a
Internet: gt0178a at prism.gatech.edu



More information about the Comp.unix.questions mailing list