Script to update Property Entry Values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to update Property Entry Values
# 1  
Old 02-16-2010
Script to update Property Entry Values

Hi All,

I'm Raghavendra. I have a very urgent requirement to develop a Shell Script which will allow to use variables in a property file as demonstarted below

var1=UNIX
var2=LINUX
var3=WINDOWS
var4=$var1,$var2
var5=$var3

Could you please help me to develop a shell script which can take the property file as shown above as the input and creates a new file by replacing the variables with actual values as shown below.

var1=UNIX
var2=LINUX
var3=WINDOWS
var4=UNIX,LINUX
var5=WINDOWS

Thanks & Regards,
Raghavendra
# 2  
Old 02-16-2010
Code:
$ cat data
var1=UNIX
var2=LINUX
var3=WINDOWS
var4=$var1,$var2
var5=$var3

$ while read x; do eval "$x"; eval echo "\"$x\""; done < data > result

$ cat result
var1=UNIX
var2=LINUX
var3=WINDOWS
var4=UNIX,LINUX
var5=WINDOWS

# 3  
Old 02-16-2010
Hi Alister,

Thanks so much for your help. Its Working. I'm very new to Shell Scripting. Could you please brief the solution in 2 or 3 sentences if it dont disturbs you. Thanks in Advance

Best Regards,
Raghavendra
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. How to Post in the The UNIX and Linux Forums

Help me, write a bash script to delete parent entry with all their child entry in LDAP UNIX server

Hi All, Please help me and guide me to write a bash/shell script on Linux box to delete parent entry with all their child entries. example: Parent is : ---------- dn: email=yogesh.kumar@wipro.com, o=wipro, o=in child is: ---------- dn: cn: yogesh kumar, email=yogesh.kumar@wipro.com,... (1 Reply)
Discussion started by: Chand
1 Replies

2. Shell Programming and Scripting

How to update an entry of another file in a Shell script?

Hi all, Say I have a shell script called update_password.sh - in this script I want to perform a task to update a specified entry of another file (e.g. users.passpords) update_password.sh #!/bin/bash -e PW_FILE_DIR="${A_DIR}/.../..." PW_FILE="users.passwords" I want to update the... (2 Replies)
Discussion started by: isaacniu
2 Replies

3. Shell Programming and Scripting

unique entry add values

Hi, I have a file with 3 columns ABC 3 1 ABC 5 1 XYZ 4 2 DEF 3 2 DEF 4 1 DEF 6 1 MNO 5 5 JKL 3 2 JKL 4 2 PQR 12 1 For each unique entry in column 1 I want to add values in column 2 and column3 o/p ABC 8 2 XYZ 4 2 (1 Reply)
Discussion started by: Diya123
1 Replies

4. Shell Programming and Scripting

Reading a property file through shell script???

Hi! i need a script that can read a property file. i.e., A script to read a "property" from property file. Read the property value and based on value of property, decide whether to start the some dataload activity or not. Its urngent. Can anyone help me out???:( (7 Replies)
Discussion started by: sukhdip
7 Replies

5. Shell Programming and Scripting

Report a missing property and property value mis match script.

Hi All, I have 2 properties files - one is a master templete and other one is a node specific properties file, I need to comapre these 2 properties files and make sure the node Specific properties file contains all the properties in the master temple properties file else report the missing... (5 Replies)
Discussion started by: jayka
5 Replies

6. UNIX for Dummies Questions & Answers

Script to update values for the parameters

Hello, I am writing script to substitute values for a parameter in the file but I am getting error. for v1 in grep "pProjectName=" global.cfg do sed -e "/s/$v1/pProjectName=Test/ global.cfg done Please correct me if I am wrong, thanks in advance (1 Reply)
Discussion started by: gmahesh2k
1 Replies

7. Programming

/etc/shadow update password entry! ( getspent? )

Hi i just whant to update an password entry in /etc/shadow. But dosen't get it to work. Something is wrong! in this code. What i try do do is if user kalle exist in shadow. I whant it to update it's password for just that entry. #include <stdio.h> #include <errno.h> #include <stdlib.h>... (2 Replies)
Discussion started by: nighter
2 Replies

8. UNIX and Linux Applications

Edit/update an /etc/group database entry (c/c++)

Hello I'm writing a program for managing accounts and groups in a linux system. My problem is how to update the members of a group in the /etc/group file,if i have to add/remove those members. total 3 variables for adding some new members to the group : char **oldmembers=grp->gr_mem; ... (1 Reply)
Discussion started by: mekos
1 Replies

9. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies
Login or Register to Ask a Question