[plug] Lists in BASH
Garth Atkinson
garth at cclinic.com.au
Sat Aug 19 17:30:39 WST 2000
Bash 2.0 has associative arrays, bash 1.4 doesnt. I'm not sure what
you are trying to do with example you supplied.
Do you want variable lists like in Python?
ie
data="matt,leon,tony"
for reprobate in data
print reprobate
would give you:
matt
leon
tony
To achieve the above in bash you need something like this
(untested):
data="matt,leon,tony"
IFS=","
data="NOTZEROLENGTH"
while [ -z "$data" ] ; do
echo $data | read reprobate data
echo $reprobate
done
(I am assuming data gets set to zero length in the fourth loop)
Garth
skribe wrote:
>
> How do I assign a text list to a variable in bash?
>
> ie
>
> data=matt,leon,tony
>
> skribe
> Purity: 62.0%
> Corruption: 38.0%
> Insanity: 36.3636363636364%
> Weirdness factor: 31%
> Experience Level: JonKatz Wannabe
> Medieval Career: Black Knight
More information about the plug
mailing list