View the Most Wanted LQ Wiki articles.    
LinuxQuestions.org > Linux Wiki > Getopt

From LQWiki

Jump to: navigation, search

Getopt parses a parameters string and outputs it in a normalized format. Imagine you want to write your own bash script foo that takes options. It should be no matter if the user calls it

foo -abcd

or

foo -a -b -c -d

getopt normalizes the parameters:

scorpio:~ # getopt abcd -abcd
 -a -b -c -d --

The first parameter tells getopt which options are allowed (a,b,c and d in this case), the second parameter is the string to be normalized.

See also



Personal tools
Sponsored Links