Use Hashes in Bash Scripts (Rated 0)Description:
Hash data structure are very convenient. They
let you use strings as indexes instead of numbers.
The value script, shown below, demonstrates
how to use Bash's eval command to simulate a
hash structure.
The command, "value david" would print
"The email address for david is
medined@planet.net". Code starts here
#!/bin/bash
email_phil="phil@rigel.ipal.net"
email_david="medined@planet.net"
eval 'email=${email_'"${1}"'}'
echo "The email address for ${1} is ${email}"
Submitted by Devscripts on 24-02-2003 12:01 |