creating a parameter file in the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting creating a parameter file in the script
# 1  
Old 04-07-2011
creating a parameter file in the script

Here is my code which i am using wright now:
CODE
Code:
#!/bin/bash
awk ' BEGIN { FS="|"; 
while ( getline <"file1.txt" >  0) 
   a[$1]=$2 
} 
{ 
if($1 in a) 
    printf("%s %s Specialty Mapped\n", $1, a[$1]) > "mapped.txt" 
else 
    printf("%s %s Specialty Not mapped\n", $1, $2)  > "notmapped.txt"
    
} ' file2.txt

So here file1.txt is static in nature but file2.txt changes i.e i am having many multiple files like file2.txt with different names which has to do the same work with the code.
So what i want is to parametrize the file file2.txt inside the code so that when ever i want to use another file i have to just change the name of the file instead of file2.txt and it will work as same for the code.
So any kind of help will be appreciated.

Last edited by Franklin52; 04-07-2011 at 03:32 AM.. Reason: Please use code tags
# 2  
Old 04-07-2011
I take it you are not going to pass the filename as a parameters from the command line? ($3)

Please refer to the following link on using source files

https://www.unix.com/shell-programmin...ll-script.html

Hope this helps
# 3  
Old 04-07-2011
hey it worked, i got the solution..

Last edited by dsh007; 04-08-2011 at 03:38 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How pass the input parameter to a file in the script ?

OS version: RHEL 6.7 myTextFile.txt file is referred within Script1.sh script, I only execute Script1.sh and I want the input variable to be passed inside myTextFile.txt . Any idea how I can do this ? $ cat script1.sh cat myTextFile.txt $ cat myTextFile.txt $1 Requirement1.... (4 Replies)
Discussion started by: kraljic
4 Replies

2. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (3 Replies)
Discussion started by: Debalina Roy
3 Replies

3. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (2 Replies)
Discussion started by: Debalina Roy
2 Replies

4. Shell Programming and Scripting

Read parameter file for a shell script

Hi All, I need urgent Help from all of you here. Below is my code- ================================================== #!/usr/bin/sh cd $1 cat $2 | tr -ds "$" "" > parameter_file.param export `parameter_file.param` chmod 777 parameter_file.param echo $1 echo $2 cd $prmDirInput... (5 Replies)
Discussion started by: Amit786
5 Replies

5. Shell Programming and Scripting

Script to parse and update a parameter file

Dear All- My requirement is as below, need your inputs please 1] I have a file name Param.txt which contains the below data #GLOBAL# PARAM_VALUE=N ............. ............ CTRY=UK ......... 2] Next, I want to write a script which will check for some condition (lets assume... (1 Reply)
Discussion started by: sureshg_sampat
1 Replies

6. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

7. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

8. Shell Programming and Scripting

Passing parameter from one file to shell script

Hi All, I have a 2 files. File1 i am generating using an ETL tool, which is a comman seperated delimited file which contains country code & load date. everytime, this country code will be updated from a table. It might be AB or BA & ld_date will be for which date we need to load the file. ... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies

9. Shell Programming and Scripting

Read from file as script parameter

I have a file with userIDs, one per line no spaces. I have a script that accepts userIDs as a parameter and outputs information about them. What I have had to do in the past was to modify each line of the file with userIDs to call the script with the userID and pipe the output to a data file. ... (2 Replies)
Discussion started by: vmaxx
2 Replies

10. Shell Programming and Scripting

parameter file for a shell script

Hi I was able to pass parameters to a shell script from the command line but now, I am trying to make the shell script to get those parameters/values from a file. Please give me ideas how to do this or if you have an example or website that shows how to do this. I tried searches but it... (2 Replies)
Discussion started by: bryan
2 Replies
Login or Register to Ask a Question