Shell 13th question 2: Relationship between shell prompt (PS1) and carriage return (CR)

Source: Internet
Author: User

After you successfully log on to a text interface, in most cases,

You will see a flickering square or bottom line on the screen (depending on different versions ),

We call it a * cursor * (cursor ).

The cursor is used to tell you where the button you entered from the keyboard is inserted,

Each input one-click cursor moves a grid to the right. If too many entries are input consecutively, the cursor is automatically input in the next row.

If you have just completed the login and have not entered any buttons, you will see the cursor in the left part of the same row in the position,

We call it the * prompt ).

The format of the prompt symbol varies depending on the system version. in Linux, you only need to pay attention to a visible prompt symbol closest to the cursor, which is usually one of the following:

$: Used by a general user account

#: Used by the root (Administrator) Account

In fact, shell prompt is simple:

* Shell tells the user that you can enter the command line now.

We can say that the user can run the command line only when obtaining the shell prompt,

Cursor indicates the position of the keyboard input in the command line. Each time a user inputs a key, the cursor moves one cell backward,

Until the command line reads Cr (carriage return, generated by the Enter key) characters.

CR also means very simple:

* The User told shell: Dude, you can execute my command line.

Strictly speaking:

* The so-called command line is the text entered between shell prompt and Cr.

(THINKING: Why do we insist on using the CR character instead of the Enter key? The answer will be revealed in later learning .)

Different command line formats may vary. Generally, a standard command line format is listed as follows:

Command-name options argument

From the technical details, shell splits the text entered by command line into "field" (Word) based on IFS (internal field seperator ).

Then, the special characters (Meta) are processed first, and then the entire line of command line is reorganized.

(Note: Please be sure to understand the meaning of the last two sentences. We will often come back here for future study .)

IFS is the bar Separator Used by Shell preset. It can be composed of one or more of the following buttons:

* White space)

* Table key (Tab)

* Enter)

Command-name can be obtained from the following methods:

* Specify the external commands specified by the path

* Command alias (alias)

* Custom Functions)

* Shell built-in commands (built-in)

* $ External commands under path

Each command line must contain a command name, which is indispensable.

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.