Linux Command Line Parameter Processing

Source: Internet
Author: User
Article Title: linux Command Line Parameter processing. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Linux follows a unified command line format. there are usually two expressions: short format vs long format. The short format is composed of a "-" plus characters, such as-h,-v,-l filepath, and so on. The long format is composed of two "-" And one word, such as -- help, -- version, and -- load filepath.

① Short-format Command Options are represented by a "-" and a single English letter, for example, "-".

② Long format Command Options: Two "-" and an English word, such as "-- help ".

Most Linux commands provide short format and long format options for the implementation of the same function. Short format options are simple in structure and quick in input. long format options have clear meaning and are easy to remember.

◇ POSIX conventions on program names and parameters ◇

The program name should not be less than 2 Characters and no more than 9 characters.

The program name must contain only lowercase letters and Arabic numbers.

The option name must be a single character or a single number prefixed.

You can merge multiple options without option parameters. For example, foo-a-B-c is equivalent to foo-abc.

Options and their parameters are separated by a blank space.

Optional.

If the option parameter has multiple values, it must be passed in as a string, for example, myprog-u "arnold joe jane ".

The option should appear before the operand appears.

The special parameter "--" indicates that all parameters are completed, and any subsequent parameter is considered as the operand.

It does not matter how the options are arranged. For mutex options, if the operation result is overwritable, the last option takes effect.

The sequence of allowed operands affects program behavior, but it must be documented.

The program that reads and writes a specified file should treat a single parameter '-' as a meaningful standard input or output.

◇ GNU long option conventions ◇

For GNU programs that have followed the POSIX conventions, each short option has a corresponding long option.

Additional Long Options for GNU do not need the corresponding short options. We recommend that you have them.

The length option can be abbreviated as a string with the minimum uniqueness.

The option parameter and the long option are separated by a '=' or by a blank character.

The option parameter is optional (only valid for the short option ).

The length option can be prefixed with a dash.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.