getopt man page on Xenix

Man page or keyword search:  
man Server   1130 pages
apropos Keyword Search (all sections)
Output format
Xenix logo
[printable version]



     GETOPT(C)		      XENIX System V		     GETOPT(C)

     Name
	  getopt - Parses command options.

     Syntax
	  set -- `getopt optstring $*`

     Description
	  getopt is used to check and break up options in command
	  lines for parsing by shell procedures.  Optstring is a
	  string of recognized option letters (see getopt(S)).	If a
	  letter is followed by a colon, the option is expected to
	  have an argument which may or may not be separated from it
	  by whitespace.  The special option -- is used to delimit the
	  end of the options.  getopt will place -- in the arguments
	  at the end of the options, or recognize it if used
	  explicitly.  The shell arguments ($1$2...) are reset so that
	  each option is preceded by a dash (-) and in its own shell
	  argument; each option argument is also in its own shell
	  argument.

     Example
	  The following code fragment shows how one can process the
	  arguments for a command that can take the options a and b,
	  and the option o, which requires an argument:

	  set -- `getopt abo: $*`
	  if [ $? != 0 ]
	  then
	       echo $USAGE
	       exit 2
	  fi
	  for i in $*
	  do
	       case $i in
	       -a | -b)	 FLAG=$i; shift;;
	       -o)	 OARG=$2;  shift; shift;;
	       --)	 shift;	   break;;
	       esac
	  done

	  This code will accept any of the following as equivalent:

	       cmd -aoarg file file
	       cmd -a -o arg file file
	       cmd -oarg -a file file
	       cmd -a -oarg -- file file

     See Also
	  sh(C), getopt(S)

     Diagnostics
	  getopt prints an error message on the standard error when it

     Page 1					      (printed 2/7/91)

     GETOPT(C)		      XENIX System V		     GETOPT(C)

	  encounters an option letter not included in optstring.

     Notes
	  The ``Syntax'' given for this utility assumes the user has
	  an sh(C) shell.

     Page 2					      (printed 2/7/91)

[top]
                             _         _         _ 
                            | |       | |       | |     
                            | |       | |       | |     
                         __ | | __ __ | | __ __ | | __  
                         \ \| |/ / \ \| |/ / \ \| |/ /  
                          \ \ / /   \ \ / /   \ \ / /   
                           \   /     \   /     \   /    
                            \_/       \_/       \_/ 
More information is available in HTML format for server Xenix

List of man pages available for Xenix

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net