Pete's Linux Advent Calendar 2008

The 19th day

Create pseudo associative arrays in Bash

Here's a simple method to create sort-of associative arrays:
#!/bin/bash
# first the indices
fruit=0
people=1
languages=2

# use the indices to initialize the array
ar[$fruit]="apple banana kiwi"
ar[$people]="Linus Richard Matthias"
ar[$buildings]="Bash Python Perl"

Pete's Linux Advent Calendar 2008

Valid HTML 4.01!

Comments? send mail to pkruse@arcor.de my monogram