Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Next: , Previous: Mnemonic Options, Up: Styles


3.3.2 Short Option Style

Most options also have a short option name. Short options start with a single dash, and are followed by a single character, e.g., -t (which is equivalent to --list). The forms are absolutely identical in function; they are interchangeable.

The short option names are faster to type than long option names.

Short options which require arguments take their arguments immediately following the option, usually separated by white space. It is also possible to stick the argument right after the short option name, using no intervening space. For example, you might write -f archive.tar or -farchive.tar instead of using --file=archive.tar. Both --file=archive-name and -f archive-name denote the option which indicates a specific archive, here named archive.tar.

Short options which take optional arguments take their arguments immediately following the option letter, without any intervening white space characters.

Short options' letters may be clumped together, but you are not required to do this (as compared to old options; see below). When short options are clumped as a set, use one (single) dash for them all, e.g., ‘tar -cvf’. Only the last option in such a set is allowed to have an argument1.

When the options are separated, the argument for each option which requires an argument directly follows that option, as is usual for Unix programs. For example:

     $ tar -c -v -b 20 -f /dev/rmt0

If you reorder short options' locations, be sure to move any arguments that belong to them. If you do not move the arguments properly, you may end up overwriting files.


Footnotes

[1] Clustering many options, the last of which has an argument, is a rather opaque way to write options. Some wonder if GNU getopt should not even be made helpful enough for considering such usages as invalid.


 
 
  Published under the terms of the GNU General Public License Design by Interspire