Unix Tip #4473- June 10, 2023


SEARCH : Home : Help : Today's Tip

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@PHL.Boeing.com



NOTE: All tips provided are USE AT YOUR OWN RISK. Tips are submitted by various unix admins around the globe. UGU suggest you read and test each tip in a non-volitile environment before placing into production.


LAST 5 TIPS
4472 - BE A GURU - RTFM
4471 - ONE STEP AT A TIME WITH !!
4470 - PRINTING WITH NO SPACE
4469 - To grab all hidden files
4468 - SAVE A COPY


I want to SUBSCRIBE and get a UGU Tip everyday.
I want to UNSUBSCRIBE and NOT get a UGU Tip everyday.

If you have a UNIX TIP let us know, we just may use it:
(All tips become the property of the Unix Guru Universe)
Email Address:

Yes, email me a Hot Unix Tip everday.

Enter Hot Unix Tip (optional):

Yes, I will support this tip

Captcha (not case sensitive):


Please enter the above letters:


HOME | Flavors | Admin | Network | Security | S/W | Help | Events | Vendors | Careers | Internet
About | Add Link | Feedback | Search

Copyright © 1994-2005 Unix Guru Universe