arrays in sh (was: Novice questions about shell syntax)

Maarten Litmaath maart at cs.vu.nl
Thu Aug 9 01:59:11 AEST 1990


In article <637 at travis.csd.harris.com>,
	brad at SSD.CSD.HARRIS.COM (Brad Appleton) writes:
)...
)	2) set a shell variable to a word-list (or an array)
)...
)     sh                       ksh                    csh
)  -------------------   ----------------------   --------------------------
)...
)2)    N/A               set -A name el1 el2 ...  set name=( el1 el2 ... )

To emulate arrays in sh the following constructs can be used:

	# to set `array[index]'
	eval array$index=\$value

	# to retrieve it
	eval value=\$array$index
--
   "UNIX was never designed to keep people from doing stupid things, because
    that policy would also keep them from doing clever things."  (Doug Gwyn)



More information about the Comp.unix.questions mailing list