Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Processing and reading properties files using shell script

Status
Not open for further replies.

ringd

Programmer
Jul 11, 2000
35
GB
Hello!

Has anyone come across / written any good code samples which they would like to share(!) for shell script reading a properties file or hash table? The shell array processing has limitations which appear to make this task look a little tricky.

In the meantime, I'll try a solution which is a psuedo-multi-dimensional array for "key/value" pairs. This is using 2 separate arrays; 1 for the key and 1 for the value. Both arrays will share a comman index.

Cheers,
Dave.
 
Not sure I fully understand yuor question but;

you can do the following

name[1]=mike
name[2]=dave

or

set -A name mike dave bob

this would set mike to name[0], dave to name[1], bob to name[3]

so all you have to do is read the properties file and assign each field.

Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
or try the following

cat /etc/passwd | while IFS=: read f1 f2 f3 f4 f5 f6 f7 f8
do
if [ $f3 !="0" ];then
echo $1 is not root
fi

Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
@ringd,

Not sure I fully understand either. Can you post samples of what you have tried so far?


Regards,
Chuck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top