Is it possible to find parameters?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is it possible to find parameters?
# 1  
Old 06-22-2006
Is it possible to find parameters?

I have a shell script and i pass 3 parameters to it.
Just give you an example

test.sh a=y/n b=y/n c=y/n

Pass y/n to a, b and c then it will decide what to do.

test.sh a=y b=n c=n

What i would like to do is rather then passing 3 parameter just pass a=y (only a is doing something like test.sh a=y) and skip others.
Now don't know if it is possible to look for something in parameters?
(Something like find if a,b and c have given to script always there will be one parameter).
Some scenarios

test.sh a=n b=y c=n
What i want test.sh b=y (skip a & c don't pass because no need)
test.sh a=n b=n c=y
What i want test.sh c=y (skip a & b don't pass because no need)

Thanks in advance.
# 2  
Old 06-22-2006
I think that can be do

Code:
for i in "$@"
do
  if [ `echo $i` = y ]
  then
    #do everything you want
  fi
done

Bye

Last edited by Don Cragun; 07-29-2014 at 04:28 PM.. Reason: Add CODE tags.
# 3  
Old 06-23-2006
What shell? Try looking for getopts / getopt.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find the year and assign to different parameters

Hi All, I have a unix directory and under which the below set of files(Years will change) will be there ##################################### TEST_DETAIL_HCR_ABC2015_T01152015.csv TEST_DETAIL_HCR_ABC2014_T01152015.csv TEST_DETAIL_HCA_ABC2013_T01152015.csv I need to assign years to... (2 Replies)
Discussion started by: weknowd
2 Replies

2. UNIX for Dummies Questions & Answers

Perl Script:how to find how many parameters are required to run the script

How to find how many parameters are required to run a Perl script? (1 Reply)
Discussion started by: Lakshman_Gupta
1 Replies

3. Shell Programming and Scripting

Passing wildcard parameters to find via a variable

I have a script to fix permissions which is made up of blocks like: FS_ROOT=/home/shared/Photos FS_EXCLUDE=( \( -path */.webviews -o -path */.thumbnails \) -prune -o ) find $FS_ROOT ${FS_EXCLUDE} -type d -not -perm 2770 -exec chmod 2770 "{}" \; That fragment works as expected, but no matter... (3 Replies)
Discussion started by: mij
3 Replies

4. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

5. UNIX for Dummies Questions & Answers

find usage with parameters

i have this basic piece of code to look for an aging file based on an input parameter. pfile=$1 pdir=`pwd` echo current directory $pdir for i in `find . "$pfile" -mtime +540` do echo aging files $i done # put a white space echo the above code works and gives me the listing of... (6 Replies)
Discussion started by: wtolentino
6 Replies

6. Shell Programming and Scripting

More than nine parameters

Hi, please tell me the systax for passing 11 variables(including 4compulsory variables) in shell program. ORA_USERPASS=`echo $1` USERID=`echo $2` USERNAME=`echo $3` REQUESTID=`echo $4` P5=`echo $5` P6=`echo $6` P7=`echo $7` P8=`echo $8` P9=`echo $9` shift P10=`echo $9` shift... (3 Replies)
Discussion started by: anitha126
3 Replies

7. Shell Programming and Scripting

using a vaiable parameters and values to find and tar

This one took HOURS and HOURS of my life. Hopefully this post will save someone the same grief. I am using "-regex" with "find" via a variable. If I echo the command that is constructed, it looks OK. When I paste the echoed text it to the command line it runs fine. But inside the script it... (1 Reply)
Discussion started by: jjminkle
1 Replies

8. UNIX for Advanced & Expert Users

How to Find AIX system parameters

System Parameters: maximum number of processes = 2048 Network parameters: ipqmaxlen - 512 rfc1323 - 1 sb_max - 1310720 (2*655360) tcp_recvspace - 65536 tcp_sendspace - 65536 Udp_recvspace - 655360 Udp_sendspace 65536 (1 Reply)
Discussion started by: R00tSc0rpi0n
1 Replies

9. Shell Programming and Scripting

parameters

I have a script that needs to check if the given parameters are a combination of 0123456789 and not a word or another irelevant character.please help (6 Replies)
Discussion started by: aekaramg20
6 Replies

10. Shell Programming and Scripting

Need Parameters Help.

I can test for one parameter but anything more then that and I get an Error. I forgot I run this batch in a shell #!/bin/sh ------------------------------------------------------------------------- Write a batch program that accepts a keyword as a parameter and finds all the files... (3 Replies)
Discussion started by: james2006
3 Replies
Login or Register to Ask a Question