VIM, bash, etc.

Source: Internet
Author: User
Tags aliases clear screen

Use Vim to edit multiple files

Vim file1 file2 file3 ...

: Next to view or edit the contents of the latter document

: Prev View or edit the contents of a previous document

: First to view or edit the contents of a document

: Last view or edit the contents of the Final Document

Vim-o|-o file1 file2 File3

-O: Display multiple files horizontally

-O: Display multiple files vertically

Ctrl+w arrow (arrow) cursor movement

Ctrl+w,s tell a file horizontal split screen display

Ctrl+w,v a vertical split-screen display of a file

: QA All exits

: wa All saved

Populate the contents of other files into the current file

: R (/path/to/somefile) this is an explanation

Interacting with the shell

:! Order (command)

Partial Save As

: W (Save All)

: M,nw (from line m to Nth line)

: M,+n

:., $w

Supported shells in the default system

Cat/etc/shells

Bash features

Command aliases: Custom commands

Alias: Aliases that can be used to define and set commands

Note: aliases defined with the alias command have a lifetime limited to the current Shell's lifetime If you modify the. BASHRC configuration file, the saved alias will not take effect immediately and will not take effect until the contents of the file are reloaded, and it is always valid for both operations

Revoke alias: Unalias

. . BASHRC: Read the command for. BASHRC

Command history:

The bash process saves the commands that the user has executed in its session, so that users can repeatedly execute a command through Bash's historical command file to persist previously executed commands, and bash automatically reads ~/.bash_ when the user logs into the shell from a private history file. All commands recorded in the history file

History command:

-C: Clears the history command from the history buffer;

-D OFFSET: Deletes a specific history command entry;

The method of repeating the previous command:

Use the UP arrow, enter to execute

Ctrl+p

!-1

!!

command to repeat the historical buffer execution

! # (#= number): Repeat the command numbered # in the history command

! (String) String: Finds the most recent executed string from the history buffer and executes

!? String: Finds the most recent command containing string from the history buffer and executes

! -Number: Executes the countdown number command in the history buffer

Ctrl+r: Implement a search in the history buffer, enter execution:

Reuse part of the history command:

! $, ESC., Alt +: represents the last parameter in the last command;

! ^: parameter of First position

! : Number: The parameter of number position in the last command

! Number1:number2 the number2 parameter of the Number1 command in the history buffer

Shortcut keys

C-->ctrl

M-->alt

E-->esc

Del-->backspace

C-l:clear Clear Screen

C-A: Jumps the cursor to the beginning of the command line

C-E: Jumps the cursor to the end of the command line

C-k: Remove command line information from the cursor position to the end of the line

C-u: Delete command line information at the beginning of the cursor position

C-c: Ends the foreground process. Canceling the run of a command

Command completion mechanism:

Completion of the command itself string

Completion of parameters

Use the TAB key to complete command completion:

If the given string cannot be uniquely identified, bash does not complete, and the TAB key is pressed again, Bash gives a reference list, and if there is too much content in the reference list, Bash asks if the list is displayed, and if the parameter does not have any prompt information, The default is to find from the working directory;

Command line expansion:

~:bash will automatically expand it to the home directory of the currently logged in user

~string:bash automatically expands it to the home directory of the user named user as STRING

~+: Invoking the value of the shell variable pwd

~-: Calling the value of the shell variable Oldpwd

{}: In curly braces you can populate a list of paths separated by "," and bash expands it into multiple independent paths;

Execution result of the command

There are two execution results for any Linux command:

Normal output of the command: return content related to user requirements:

": Inverted single quote, inverted quotation mark

$ (): standard Command Reference format

WC: Count the number of rows, words, and bytes in a file

-C: Show only the number of bytes

-L: Show only the number of rows

-W: Displays only the number of words

The execution status return value of the command, and the return command associated with the execution of the command

Reference features:

": Strong references

Whatever is quoted in quotation marks, bash treats it as a normal character, even if it has its own special function and function, but the single quote itself is an exception.

"": Weak references are quoted in double quotes with some special characters that still hold special meanings such as: $, \, ""

Escape function:

The escape character defined in \:bash can only cause one character to lose its special meaning.

globbing filename wildcard, referred to as glob;

Metacharacters

*: matches any character of any length, some special position "." Characters cannot be matched

? : matches any single character and only one character is matched

[]: matches any single character within the specified range, and only one character is matched

[A-z]:a,a,b,b,c,c,... Y,y,z

[A-z]:a,b,b,c,c,... Y,y,z,z

Character:

[: Lower:] All lowercase letters

[: Upper:] All uppercase letters

[: Alpha:] All uppercase and lowercase letters

[:d igit:] All decimal digits

[: Alnum:] All uppercase and lowercase letters and decimal digits

[: Space:] denotes white space characters

[:p UNCT:] All punctuation characters

Input and output redirection

The body that implements a function when using a computer is: program

program = instruction + data

Data: Files, io

Devices that can be used for input: Files

Keyboard devices, general files in the file system, network card devices, sound card devices, etc.

Devices that can be used for output: Files

Monitor, file system of regular files, network card devices, sound card equipment, etc.;

Each program will have three forms of data flow

Input data flow: The data stream for the program gets the default input data stream is the source of the keyboard

Output Data flow: The data stream that the program processes is displayed to the user the end point of the default output data stream is the display

Error data flow: The end of the default error stream that shows the result of a problem that the program cannot process or process is displayed to the user is the display

Input data streams implemented from the keyboard are called standard inputs

The output data stream to the monitor is called standard output

Error data flow to the monitor is called standard error output abbreviation standard error

FileName Descriptor: File descriptor,fd

0: Standard input, stdin

1: Standard output, stdout

2: standard error, stderr

IO redirection using non-standard device files for IO operations

Data flow input that is not done from a keyboard device can be called input redirection or redirection input

Not the correct output data stream to the display device can be called output redirection or redirected output

Incorrect output traffic to the display device can be called error redirection or redirect error

Output redirection:

Overwrite output redirection

set-c turn on the anti-false override switch ">|" You can continue overwriting redirects

Set +c off anti-false override switch

>>: Append output redirection

Error redirection

2>: Overwrite error redirect

2>>: Append error redirect

Merging the redirection of standard input and standard output

&>,&>>

Command>|>>/path/to/somefile 2>&1

/dev/null: Black Hole blackhole

Enter redirection:

<: Unique characters

<<: Documents here

<<<: string here

Pipeline:

|:command1 |command2 |command3 ...

Note: All commands for pipeline linking should be commands that can have standard output data streams

VIM, bash, etc.

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.