[olug] Unix Tip: BOURNE SHELL PSEUDO HASH TABLES

Unix Guru Universe listserv at ugu.com
Fri Jul 18 16:43:43 UTC 2003


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

			      UNIX GURU UNIVERSE 
			         UNIX HOT TIP

			Unix Tip 2025 - July 18, 2003

		    http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


BOURNE SHELL PSEUDO HASH TABLES

The best way to explain this 
is with an example:

You may want to write a simple 
script that launches an xterm 
window with different color 
options.  Pseudo hash tables in 
bourne shell.

$ xwindow MidnightBlue

An easy way to this is by first 
listing the supported colors in 
the script (pseudo hash table):

DarkSlateGrey="#2f4f4f"
DimGrey="#696969"
MidnightBlue="#191970"
NavyBlue="#000080"

Next, simply grab the hex color 
code by using the following 
command:

BGColor=`eval echo $"$(echo $1)"`

"$(echo $1)" evaluates to "MidnightBlue" and
`eval echo $MidnightBlue evaluates to "#191970".

Simply launch the xterm window 
using $BGColor as the background 
color:  

xterm -bg="$BGColor" &

This method for extracting pseudo hash 
values may be used for NIS map files, 
file date stamps, GUI colors, etc.


This tip generously supported by: Jasper.Silvis at PHL.Boeing.com




--------------------------------------------------------------------------
To Subscribe:    http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe:  http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX 
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU  ADVISES THAT 
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips at ugu.com - Copyright 1994-2001
==========================================================================



More information about the OLUG mailing list