Help in creation of parameter file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in creation of parameter file
# 1  
Old 02-24-2012
Help in creation of parameter file

Hi Guys,

I have a parameter file.
Sample of it as below:
Code:
Name=unix
Country=United States

I want the output as follows
Code:
-param Name=unix -param Country='United States'

I am able to achieve appending the "-param" in front.

But unable to append single quotes (') before and after the country.

This is the code i am using.
Code:
Paramfile=/test/unix/param.prm
Parmfile=`awk '{printf("-param %s ", $0)}' $ParmFile`

Can somebody help me out with this.

Cheers!!!!!!
# 2  
Old 02-24-2012
Code:
sed 's/\([^=]*\)=\(.*\)/-param \1='\''\2'\''/' inputfile | paste -d" " -s

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 02-24-2012
Code:
awk -F= 'NR>1{printf " "}{printf "-param "$1 "=\047" $NF "\047"}END{print RS}' ORS=" " input

Code:
awk -F= 'NR>1{printf " "}{printf "%s","-param "$1 "=\047" $NF "\047"}END{print RS}' ORS=" " input

Code:
 sed "s/=/=\\\'/;s/.*/-param &\\\'/" input | xargs

Code:
sed "s/=/=\x27/;s/.*/-param &\x27/" input | paste -sd" "

Code:
sed "s/=/='/;s/.*/-param &'/" input | paste -sd" "


Last edited by ctsgnb; 02-24-2012 at 08:12 AM..
# 4  
Old 02-24-2012
Thanks man.. That was real quick... ll let you know once i reach office. Smilie

---------- Post updated at 06:57 PM ---------- Previous update was at 05:23 PM ----------

Guys,

When i am running the awk command,

Code:
awk -F= 'NR>1{printf " "}{printf "-param "$1 "=\047" $NF "\047"}END{print RS}' ORS=" " input

But when i am running it in script, i am getting "\" along with single quotes(').

Actually it is passing it to some other program which is not able to recognize it..

It is passing like this.

Code:
echo $Parmfile
+ echo -param 'DbName='\''GMNGSRDB'\''' -param 'DbUser='\''NGSRALL'\''' -param 'DbPass='\''NGSRALL'\''' -param 'SrcLocation='\''/appl/data/VSTAR/global_daily/landing/GMKOREA'\''' -param 'SrcFile1='\''gmkoreacom_dly_sls_20120126165859.txt'\''' -param 'SrcFile2='\'''\''' -param 'IpLocation='\''/appl/data/VSTAR/global_daily/input/'\''GM' KOREA 'COMPANY'\'''\''' -param 'IpFile='\''gmkoreacom_dly_sls_20120126165859.txt'\''' -param 'OutLocation='\''/appl/data/VSTAR/global_daily/output'\''' -param 'BatchTrkId='\''22222'\''' -param 'BusinessUnit='\''GM' KOREA 'COMPANY'\''' -param 'Country='\''SOUTH' 'KOREA'\''' -param 'CurrSlsDate='\''2012-01-25'\''' -param 'PriorSlsDate='\''2010-01-25'\''' -param 'CurrSlsMth='\''2012-01-01'\''' -param 'CurrMnthStartSlsDate='\''2012-01-01'\''' -param 'PriorMnthStartSlsDate='\''2010-01-01'\''' -param 'CurrYrStartSlsDate='\''2012-01-01'\''' -param 'PriorYrStartSlsDate='\''2010-01-01'\''' -param 'OutFile1='\''Gbldly_D_Ods_DlySls_RefVal_010.GMKOREA.txt'\''' -param 'OutFile2='\''GblDly_D_Ods_DlySls_SalesFactFileCreation.GMKOREA.txt'\'''

Can somebody help me out here.

Cheers!!!!!!!!
# 5  
Old 02-24-2012
What you see is just an information line : the "+" at heading of your line means that you are in a debug mode : i suppose you have a set -x in your script ... (or something similar that enable the debug mode)

the \' as displayed in debug mode will just be display correctly.

Here is a simple example that you can manually test :

Code:
echo -param 'DbName='\''GMNGSRDB'\'''

as result you will get
Code:
-param DbName='GMNGSRDB'

# 6  
Old 02-24-2012
Through Sed..
Code:
[mkt@michael]$ sed -n 'H
> ${
> x
> s/=\([a-zA-Z ][a-zA-Z ]*\)/="\1" /g;s/\n/-param /gp
> }' inputfile
-param Name="unix" -param Country="United States"
[mkt@michael]$

# 7  
Old 02-24-2012
If you have the option, a better design for the parameter file would be to use unix Shell syntax,
then you could execute the file as . ./filename.
(i.e. This is the technique used extensively by system "rc" scripts).

Code:
Name="unix"
Country="United States"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print the specific part of the file name with file creation date?

Hello Folks, I have an requirement, where i need to get total count of the file based on creation date with there filename selected pattern. Filename: MobileProtocol.20171228T154200.157115.udr I want to get the count of files created on each day based on a pattern find. find . -type... (7 Replies)
Discussion started by: sadique.manzar
7 Replies

2. Shell Programming and Scripting

How to get the parameter value from the parameter file in perl?

hi all, i have a parameter file of following format, i want a method which can get the value of specific parameter. parameter file format: <Parameter Name="FileLocationWindows"> <Description> The directory location of the logger file. ... (1 Reply)
Discussion started by: laxmikant.hcl
1 Replies

3. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

4. Shell Programming and Scripting

File creation

Hi I need to write a file with value value from Paramer which is passed from datastage. It should overwrite the file if already exists. Can anybody provide command for this? (1 Reply)
Discussion started by: cnrj
1 Replies

5. Shell Programming and Scripting

Help with creating a text file in perl with file creation date.

Hi, I am quite new to Perl scripting and i need to create a .TXT file using perl, with fields (A,B,C,D,E), and this text file should be named with current file creation date "XYZ_CCYYMMDD.TXT" (i.e.XYZ_2011042514:33 PM). Can anyone who has done this, please share their expertise on this... (5 Replies)
Discussion started by: msrahman
5 Replies

6. Solaris

gzip a file and append creation date stamp to file

I want to gzip a file and append the creation date to the end of the file. How can I accomplish this task. Basically they are log files which need a creation date stamp appended to make sure they do not overwrite other log files. -jack (3 Replies)
Discussion started by: jacktravine
3 Replies

7. UNIX for Advanced & Expert Users

file creation

Hi, Is there any way to restrict directories with one type of file creation. regards. (8 Replies)
Discussion started by: guguli
8 Replies

8. Shell Programming and Scripting

file creation

hi guys Kindly see the below script #!/bin/bash if then # check to see if file notrouter exits or not if ! ls -l notrouter /root/joy/ >/dev/null then touch /root/joy/notrouter else echo "Entries already exist" fi else echo "Entries does not exist" fi here... (1 Reply)
Discussion started by: whizkidash
1 Replies

9. Linux

creation of a file

how to create a file with the same modification time as another file is having using the copy command? (1 Reply)
Discussion started by: infyanurag
1 Replies

10. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies
Login or Register to Ask a Question