The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-21-2009
sachin4sachi sachin4sachi is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 4
Generate PARAMETERS from config file

Hi,

I have a config file like below:

Code:
config.cfg
==========

PARAm_1_MIN=20
PARAM_1_MAX=40

PARAM_2_MIN=3
PARAM_2_MAX=40

PARAM_3_MIN=0
PARAM_3_MAX=4.5

.....
...
...

PARAM_N_MIN=20
PARAM_N_MAX=30
I need to write a shell script which reads this file and generated a variable PARAM_1 = (PARAM_1_MIN + PARAM_1_MAX)/2
Code:

for entry 
PARAM_1_MIN = 30
PARAM_1_MAX = 60

I should have a variable ( can be an array)  PARAM_1 or PARAM[1]= (PARAM_1_MIN + PARAM_1_MAX)/2
and so for all the other PARAMETERS in the config.cfg file. based on the number of arguments we have we should generated
so many variables in the shell script.

Could someone please help me how to do this.

Thanks
Sachin

Last edited by sachin4sachi; 04-21-2009 at 07:14 PM..