Shell operations and simple programming (III)

Source: Internet
Author: User

Shell Basics

The first word entered in the command line must be the name of a command, and the second word is the option or parameter of the command. Each word in the command line must be separated by spaces or tabs. The format is as follows:
$ Command Option Parameters
The option is a code that contains one or more letters. It has a minus sign (minus sign is necessary, and Linux uses it to differentiate options and parameters ), option can be used to change the type of the command execution action.
For example: [root @ start root] # ls
This is an LS command without any options. You can list all the documents in the current directory, but only the names of each document are listed without displaying more information.
[Root @ start root] # ls-l

Total 16

-RW-r -- 1 Root 1282 October 10 2002 anaconda-ks.cfg

Drwx ------ 4 Root 4096 March 17 Desktop

Drwxr-XR-x 3 Root 4096 October 10 2002 gnustep

Drwxr-XR-x 3 Root 4096 March 17 PIC

The-L option is added to list detailed information for each document, such as the data size and the last modification time.

Most commands are designed to accept parameters. A parameter is one or more words entered after the option in the command line, for example

[Root @ start root] # ls-l PIC

Total 760

-RW-r -- 1 Root 74402 March 17 1.jpg

-RW-r -- 1 Root 64094 March 17 2.jpg

-RW-r -- 1 Root 55293 March 17 3.jpg passwd

All documents and their information under the PIC directory are displayed.

Some commands, such as LS, can contain parameters, while some commands may require some minimum parameters. For example, the CP Command requires at least two parameters. If the number of parameters does not match the command requirements, shell will report an error. For example:

[Root @ start root] # cp anaconda-ks.cfg/tmp/

Note: The options in the command should be input before the parameter.

The command line is actually a text buffer that can be edited. You can edit the input text before pressing enter. For example, you can use the backspace key to delete the just-typed characters, delete the entire line, and insert characters so that when you enter a command (especially a complex command, if an error occurs, you do not need to re-enter the entire command. You can use the edit operation to correct the error.

The up arrow can be used to re-display the just-executed command. This function can be used to re-execute the previously executed command without re-typing the command.

Bash stores the list of commands you have previously typed. This list is called the command history table. Click the arrow to display each command on the command line. Similarly, you can move the down arrow in the command list to display previous commands on the command line. You can modify and execute these commands.

Multiple commands can also be placed in one command line, separated by semicolons. These commands are executed in order. For example:

[Root @ start root] # date; LS

January 1, March 17 16:56:35 CST 2002

Anaconda-ks.cfg desktop (gnustep pic)

You can also enter a command in several command lines and use a backslash to continue a command line to the next line. For example:

$ CP-I/

Mydata/

Newdata

The preceding CP command is divided into three lines. The first two lines end with a backslash and the first line is used as a command line.

In shell, in addition to common characters, you can also use special characters with special meanings and functions. When using them, pay attention to their special meanings and scopes. The following describes these special characters.

Related Article

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.