Shell script with input parameter


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Shell script with input parameter
# 1  
Old 07-13-2005
Shell script with input parameter

Can anyone help me how to write a shell script which accepts input parameter. My requirement is as follows:

I need to run a shell script with a input parameter, and inside the script i will create a file with this input parameter name.

Please help me out to create such a shell script.

Thanks.
# 2  
Old 07-13-2005
Try this.

Code:
#! /bin/sh

if [ $# -ne 0 ]; then
        echo "Param "$@" "
        touch $@
fi;

You have to make use of $@, $# and $1 et al to make further proper use of command line parameters passed to the script.

Vino
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

3. UNIX for Dummies Questions & Answers

Passing shell script parameter value to awk command in side the script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff |... (1 Reply)
Discussion started by: Sarita Behera
1 Replies

4. Post Here to Contact Site Administrators and Moderators

Unable to pass shell script parameter value to awk command in side the same script

Variable I have in my shell script diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk -F'~' ''$2 == "$id"' {print $0}' > $new I could see value of $id is not passing to the awk... (0 Replies)
Discussion started by: Ashunayak
0 Replies

5. Shell Programming and Scripting

Script Shell Parameter

Hi I have two shell script, the second script takes as a parameter the output variable of the first script, please how to retrieve the variable from the first script to pass as a parameter to the second script? Script1.sh i=0 i=$(($i + 1)) Script2.sh echo $1 Thank you (0 Replies)
Discussion started by: chercheur111
0 Replies

6. UNIX for Dummies Questions & Answers

Parameter change in shell script

How can i chnage the parameter value in shell script. file name is icare_mmi_cls.com, iside that the parameter name is 10.100.1.2" replace the address to bep-sftp.cce.com. can you please provide me with examples. Thanks. (3 Replies)
Discussion started by: damodarreddys
3 Replies

7. Shell Programming and Scripting

Passing string as a input parameter for a shell script

Hi i have a shell script which needs a string as an input parameter. How to pass the string param as an input? In command line am running the script. for e.g., a="who is a buddy?" sh sample.sh $a Inside the script i get this input param as $1 but only the value "who" is accepted... (12 Replies)
Discussion started by: vidhyaS
12 Replies

8. Shell Programming and Scripting

Pass input and output file as parameter to awk script

Hi, i am new to awk. I am using csv2pipe script(shown below) BEGIN { FS=SUBSEP; OFS="|" } { result = setcsv($0, ",") print } # setcsv(str, sep) - parse CSV (MS specification) input # str, the string to be parsed. (Most likely $0.) # sep, the separator between the values. # #... (6 Replies)
Discussion started by: bhaskarjha178
6 Replies

9. Shell Programming and Scripting

simple shell - how to get a parameter typed in a shell script

Hi, I am new to unix and using linux 7.2. I would like to create a script that would make it easyer for me to run my java programms. At the moment I have to type java myJavaprogram I am trying to write a script that will allow me to type something like this "myscript myJavaprogram" or maybe... (4 Replies)
Discussion started by: cmitulescu
4 Replies

10. Shell Programming and Scripting

Shell script with date parameter

Hi All I have a shell script which calls all the Teradata Utiltyes . There is a sudden change in the requirment . What i'm asked to do is pass on the DATE to the shell script which should take the date automatically and run the utilityes. i.e. the date should not be passed on... (5 Replies)
Discussion started by: vinayrao
5 Replies
Login or Register to Ask a Question