Shell notes (1)

Source: Internet
Author: User

> VI copy and paste

Move the cursor to the beginning of the part to be copied. Run ESC to exit the insert mode. Press V to enter visual mode. Use hjkl to select the part to be copied.

Press Y or YY to copy

Move the cursor to the target position, press P, and paste

> Echo-e

The-e parameter allows echo to interpret characters escaped by the Backslash "\". escape characters must be caused by double quotation marks.

Echo-e

Opposite to-E, do not interpret the Escape Character "\". The default setting is as follows:

> Echo-n

Disable line breaks to terminate messages

> Script =$ (basename $0)

This is a replacement command. It can be understood as script = $ basename. Then, replace $ basename with $0.

>$ #

The number of parameters, excluding the script name itself.

Eg. VI $ # is 0; vi test $ # is 1

>$ $

PID of the process ID when the script is running

>$?

Run a command with $? Capture Command Execution return status

> $0, $1, $2...

$0 is the script file name, $1, $2 is the parameter entered during script running, with a serial number

> Shift

Script Parameters $1, $2, $3... maintain a queue. After one shift operation, $1 is removed from the queue. Then, $2 --> $1, $3 --> $2...

> $ *

Indicates the list of parameters, excluding $0, that is, the script file name.

For argv in $ * can be used to traverse parameters in the list, or you can directly use the abbreviation for argv to represent

> Here document

Starting with <, it indicates that a here document is followed. <Followed by a pair of mark, the content in the mark is the content of the here document. Mark can be one or more symbols. The mark at the end must have an exclusive row.

Shell sends all content between marks to the process as standard input.

Eg.

Cat> file1 <'end of file1'
This is a file.
It contains two lines.
End of file1

> 1> & 2

Generally, after the echo command, this output is redirected to the standard error output.

> File descriptor

Exec n> OUTFILE open an output file OUTFILE and assign it to N. Then, write data to OUTFILE and direct the output to n.

Exec m <infile open an input file infile and copy it to M. Then, read data from infile and use M to read data directly.

<& Copy an input file descriptor

> & Copy an output file descriptor

> The left operator is the file descriptor, And the right operator is the file;> & the left operator is the file descriptor.

Special case:> & n assigns a value to the standard output 1 (that is, redirects to) N

<& M assign a value of 0 to the standard input (that is, redirect to) m

Eg.

Figure 1 file descriptor example.

If no parameter exists, the standard input is copied to the standard output. One parameter is used to output the file as the input and content to the screen (standard output). Two parameters are used as the first input, the second is used as the output to copy file 1 to file 2.

> Delete

Delete A character x

Delete the current dd row

Delete the remaining word DW after the cursor

Delete the remaining part after the light changes. d $

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.