Home » Infrastructure » Unix » what is the difference between getopt, getopts, optarg
what is the difference between getopt, getopts, optarg [message #98631] Thu, 10 February 2005 19:39 Go to next message
Naveen Verma
Messages: 60
Registered: August 2004
Member
Hi
what is the difference between getopt and getopts while reading command line arguments.
How many forms are there optarg.

Regards
Verms
Re: what is the difference between getopt, getopts, optarg [message #98633 is a reply to message #98631] Sun, 13 February 2005 20:17 Go to previous message
Frank Naude
Messages: 4579
Registered: April 1998
Senior Member
Hi,

Getopt and getopts are used for processing and
validating script arguments. Read the Unix man pages
for details:

GETOPT - is a Unix/Linux Command. "man getopt":

"getopt is used to break up (parse) options in
command lines for easy parsing by shell procedures,
and to check for legal options. It uses the GNU
getopt(3) routines to do this..."

GETOPTS is a shell built-in. "man bash" or "man ksh":

"getopts is used by shell procedures to parse
positional parameters...".

Study the man pages for more details and differences.

Best regards.

Frank
Previous Topic: what is the difference between $x and ${x}
Next Topic: diff between export variable=value and export variable
Goto Forum:
  


Current Time: Thu Apr 18 14:43:53 CDT 2024