Parameter to text file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parameter to text file
# 1  
Old 06-30-2010
Parameter to text file

I have a file called filename.cg.

Which contains the hard-coded value.

Code:
Name abc
Age 23

In another script we are calling the filename.cg

perl abc.pl abc 23
should be the parameter.


In filename.cg

Code:
Name 1st parameter
Age 2nd parameter

# 2  
Old 06-30-2010
If there is a question in there, I absolutely cannot find it...
# 3  
Old 06-30-2010
Name 1st parameter
Age 2nd parameter
How to make the Name and age values to be in the parameter.

Now the filename.cg contains the hard-coded values, so how can i make that to take the arguments from the command line.
# 4  
Old 06-30-2010
u can do something like below. by reading variables.
Code:
if [[ $# -eq 0 ]] || [[ $# -gt 1 ]]
then 
echo "erorr more input given"
name=$1
age=$2

if [[ -z ${name} ]] || if [[ -z ${age} ]]
then
echo "error your parameters entered are empty.please enter parameters"
fi
done

nw ur file will take parameters from user and put another echo statement like below if u want to print name and age.

echo "$1 = name and $2 = age"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

2. UNIX for Beginners Questions & Answers

How to replace a parameter(variable) date value inside a text files daily with current date?

Hello All, we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies

3. UNIX for Beginners Questions & Answers

Need list of input and output parameter of task in a text file, using shell script

//file begin ===== //some code task abcd_; input x; input y,z; //some comment output w; //some comment reg p; integer q; begin //some code end endtask : abcd_ //some code //file end ===== expected output from above... (1 Reply)
Discussion started by: rishifrnds
1 Replies

4. Shell Programming and Scripting

Get the two parameter from text file in UNIX.

Hi there, In my attachment there is 'Category/Subcategory' & 'Setting'. var=$(awk '/^Logon\/Logoff/ {P=0} P {print $0} FNR==1{printf("From file %s:\n", FILENAME)} /^System/ {P=1}' $file |grep -ia "IPsec Driver" );echo $var As of now I am able to From File: Policies.txt IPsec... (2 Replies)
Discussion started by: alvinoo
2 Replies

5. 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

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

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

8. UNIX for Dummies Questions & Answers

Reading from a file(passing the file as input parameter)

hi I have a shell script say primary.sh . There is a file called params my scenario is primary.sh should read all the values and echo it for example i should pass like $primary.sh params output would be Abc ... (2 Replies)
Discussion started by: ssuresh1999
2 Replies

9. Shell Programming and Scripting

Getting the value from a parameter file

Hi I am nebie to Unix I have a prameter file which has semicolon seperated values which has the field STATUS_CODE;9000;1;1200;2000 The values are dynamic ie. it can be 1,2,3...any number How do i get all the values of this parameter into a variable Please if anyone can help me out on... (2 Replies)
Discussion started by: theeights
2 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