The UNIX and Linux Forums  


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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Generate XML file from C++ debu High Level Programming 2 08-04-2008 10:19 AM
To generate the FTP Script file konankir Shell Programming and Scripting 1 04-01-2008 04:16 PM
Script to generate text file from excel file isingh786 UNIX for Dummies Questions & Answers 1 01-24-2008 10:32 AM
Generate csv file rahulrathod Shell Programming and Scripting 4 01-23-2007 10:34 AM
How to generate an image file from FD Esteban UNIX for Advanced & Expert Users 1 12-22-2005 11:50 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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..
  #2 (permalink)  
Old 04-21-2009
TonyFullerMalv's Avatar
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 740
Running:

Code:
$ . ./config.cfg

Followed by script to do the maths using the variables set, will do it won't it?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0