Sponsored Content
Full Discussion: Get Options and Parameters
Top Forums Shell Programming and Scripting Get Options and Parameters Post 302360851 by Scott on Saturday 10th of October 2009 09:34:22 PM
Old 10-10-2009
bash code:
  1. #set -A ARGS $( echo "$@" | sed "s/.*-[a-z]\+ //")
  2. ARGS=( $( echo "$@" | sed "s/.*-[a-z]\+ //") )
  3.  
  4. echo "Args: ${ARGS[*]}"
  5. echo "Arg 1: ${ARGS[0]}"
  6. echo "Arg 2: ${ARGS[1]}"
  7.  
  8. while test "$1"; do
  9.   case "$1" in
  10.     -sd) echo Option sd;;
  11.     -r) echo Option r;;
  12.     -e) echo Option e;;
  13.     *) break;;
  14.   esac
  15.   shift
  16. done
  17.  
  18.  
  19. ./Test -sd -r -e Dir1/Dir2 Dir3/Dir4
  20. Args: Dir1/Dir2 Dir3/Dir4
  21. Arg 1: Dir1/Dir2
  22. Arg 2: Dir3/Dir4
  23. Option sd
  24. Option r
  25. Option e
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cp options

Hello again, Is there an option for the cp command to overwrite existing files in the destination directory? Cheers Rob (3 Replies)
Discussion started by: milage
3 Replies

2. UNIX for Dummies Questions & Answers

options

I am just beginning to learn unix and I was wondering if there was a list of all the options somewhere on the net or hidden in the man pages? Also do options always have - and then a letter, or can it be - and a number as well? Thanks! (1 Reply)
Discussion started by: terms5
1 Replies

3. Shell Programming and Scripting

getopts takes options for parameters

Here is my post with a question about getopts. I am running korn shell on Solaris 5.8. I am trying to ensure that certain options require a parameter, which is easy enough. I have found that if multiple options are entered on the command line together, but the parameter for one of the options is... (1 Reply)
Discussion started by: UCD-Randy
1 Replies

4. Post Here to Contact Site Administrators and Moderators

Advt Options ?

Hi, I was wondering if you accept advertising on your site ? Regards, (1 Reply)
Discussion started by: systemali
1 Replies

5. AIX

no options

Hi All, I have a situation here that's very fun... I have a system with AIX and iPlanet (sunOne) installed, when occurs an unknown event on the network the WebServer shows a thousand of CLOSE_WAIT connections and this number grows and grows until the webserver crashs. I read some documents... (2 Replies)
Discussion started by: nascimento.rp
2 Replies

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

7. Ubuntu

Kernel boot options removed by fault, no boot options

Hello Everyone, First of all, I highly appreciate all Linux forum members and whole Linux community. http://forums.linuxmint.com/images/smilies/icon_wink.gif. I wish you the best for all of you ! I will try to be short and concise: I am using Linux Mint 10 for 2 months on 2 ws, and all went... (3 Replies)
Discussion started by: cdt
3 Replies

8. Shell Programming and Scripting

ksh processing options and parameters

I have a requirement where I need to process both options and parameters. command line call ie xxx.ksh -sid TEST1 -search_str LOCKED user1 user2 ..... I am using the following peice of code but I am usure how I can loop through all my parameters user1, user2, ... Note at the minium... (2 Replies)
Discussion started by: BeefStu
2 Replies
All times are GMT -4. The time now is 05:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy