Multiple paramters to a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple paramters to a shell script
# 1  
Old 06-07-2007
Multiple paramters to a shell script

Hi All,

Can anyone tell me how to pass and handle 'N' parameters in a shell script.

Thanks,
Sumesh
sumesh.abraham
# 2  
Old 06-07-2007
Code:
echo $@

output:
Code:
# ./test1.sh one two three four
one two three four

# 3  
Old 06-07-2007
Sumesh,
Shell script parameters are a "$" (Dollar sign) followed by a number.
Example: $1 $2 $3 ... $n
${#} is the number of parameters.
${@} is all parameters.
To use all parameters do the following:
Code:
typeset -i mCnt=1
while [ ${mCnt} -le ${#} ]
do
  mParm=${mCnt}
  echo "mParm = "${mParm}
  mCnt=${mCnt}+1
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script for viewing multiple logs from multiple server

I am new to Shell scripting and below is my requirement. I need to search some specific word e.g. "exception" or "transaction" from log file. We have multiple env e.g. Level1 , Level2 etc and each env have Multiple boxes e.g. For Level 1 env we have "test11.test.com" , "test12.test.com". Each... (1 Reply)
Discussion started by: peeyush
1 Replies

2. Shell Programming and Scripting

Need help with shell script using multiple awks

I have a command lline script that works perfectly. cat <some_filename> | awk '$9 == 200' | awk '$10 == 10623720' | awk -F\" '{print $6}' | sort | uniq -c | sort -r I want to put this in a shell script so that we do this for multiple files(all read from a file list) and write each output to... (5 Replies)
Discussion started by: ampak
5 Replies

3. Shell Programming and Scripting

help with multiple loops in shell script

Hi Guys- I'm trying to write a script which takes date as input (mm.yy.dd) and search in the current file. If pattern doesn't exist it will then look in a backup directory and so on. being a newb i'm unable to loop over to the backup directory. hoping for some ideas, i've highlighted the... (1 Reply)
Discussion started by: Irishboy24
1 Replies

4. Shell Programming and Scripting

shell script for multiple logging

Hi All, I am preparing a script which executes following things: 1) Logs into 8 cluster one by one. 2) After logging into each cluster,it prints the cluster name & then exit from that cluster. 3) Then it logs to next cluster & peform the same task. Here is what i have written : for... (8 Replies)
Discussion started by: d8011
8 Replies

5. Shell Programming and Scripting

shell script to ftp multiple files

Hi, i use the below script to send a single file to remote server from linux. ftp -nvi <<!EOF open $Host_name user $USER_ID $PWD binary mput $file_name quit !EOF (where i... (2 Replies)
Discussion started by: pradebban
2 Replies

6. Shell Programming and Scripting

How to Read Multiple files in a Shell Script

Hi, Can any one tell me if i can read two files in a shell script... My actual requirement is to read the 1st text file and parse it to get the file code and use this file code to retrieve data from database and print the fetched data in the 2nd text file (I have parsed it and printed the... (2 Replies)
Discussion started by: funonnet
2 Replies

7. Shell Programming and Scripting

How to Use Multiple if Conditions in Shell script

if -o ] then echo "Expected valid value" The above multiple if condition is NOT working in my script. I am getting the error as '-a' not expected. Can anyone help with the syntax for this? (5 Replies)
Discussion started by: dinesh1985
5 Replies

8. Shell Programming and Scripting

runnning a shell script in multiple folders

Hey everyone, I'm fairly new to both unix and shell scripts. Right now I have a script that I can run in one folder (if a certain text file is there, do one thing, if it's not, do something else). I want to modify this to run in multiple directories. My setup is: a company directory, and within it... (2 Replies)
Discussion started by: melearlin
2 Replies

9. Shell Programming and Scripting

Multiple su - in Korn Shell script

i am trying to do something like this : #!/bin/ksh # Change to the userid user1 su - user1 #Issue the command to change directory and list files cd /home/user1/ ls -lrt exit #Come out of the user1 to root again #change to user 2 su - user2 cd /home/user2/ ls -lrt... (2 Replies)
Discussion started by: furrari
2 Replies

10. Shell Programming and Scripting

hiding sqplus paramters

Any have know how to hide the user/password paramters when doing a ps -ef when running sqlplus username/password@db from a script. (2 Replies)
Discussion started by: jinky
2 Replies
Login or Register to Ask a Question