Shell script SSH remote copy file and VI Editor

Source: Internet
Author: User
Tags file copy ssh

Many people use the simple SSH connection tool, sometimes need to copy files in SSH to the local view more convenient, I would introduce a simple command of the SCP.

The SCP is a security file copy, based on SSH login.

Easy to operate, such as to the current one file copy to a remote other host, you can follow the command

scp/lw/a root@xx.xx.xx.xx:/opt

In turn, copy remote files to local






vi Start and exit, work mode, command Daquan




VI IntroductionVI is a widely existing in various UNIX and Linux systems in the text editing program. VI is not a typesetting program, just a pure text editing program. VI is a full screen text editor, it has no menu, only commands. VI is not based on windows, so this multipurpose editing program can be used to edit a wide variety of files on any type of terminal. VI function is very powerful, but a wide range of commands, skilled mastered a certain degree of difficulty. The inventor of VI: Bill JoyLaunch of VI$ VI filename or $ VI
If filename already exists, VI opens existing file
If it is a new file, VI creates it--the test does not create a new file

VI's exitEnter in command line mode: Q,:q. ,: Wq or: X, can exit VI
: W Save
: w filename saved as filename
: wq! Save and exit
: wq! FileName is saved after filename with filename and exits
: q! Do not save exit
: x Save and exit, function and: wq! the same
vi mode of workVI has three operating modes, namely: Command mode, insert mode (edit mode) and the last line mode, three different modes of operation, they can be switched between. Command mode: Enter VI, the first is to enter the command mode, waiting for the user to enter the editing command, the letter will be entered as an edit command to explain. Insert mode: In command mode, enter the Insert command I, attach command A, open command O, and other commands can enter the insert mode, in insert mode, user input can edit the text, any characters entered are stored as the contents of the file. The ESC key returns to command mode. Last line mode: In command mode, press the ":" Key to enter the final line mode, VI cursor will be displayed in the last line of the window, to ":" As the end of the mode of the prompt, waiting for the user to enter the command. After the last line command is executed, VI automatically returns to command mode.VI Command Daquan1. Move the cursor
h or left direction key: The cursor moves one character to the left
L or RIGHT ARROW: The cursor moves one character to the right
K or UP ARROW key: Move the cursor up one character
J or DOWN ARROW: the cursor moves one character down
"Ctrl" +f: The Screen "Down" moves one page, equivalent to "PageDown"
Ctrl +b: The screen "Up" moves one page, equivalent to "PageUp"
0: Number 0, move to the front one character of this line
$: Move to the last character in this line
G: Move to the last line of this file
GG: Move to the first line of this file
N "Enter": N is a number, the cursor moves down n rows

2. Search and replace
/STR: Start at the cursor and look down for a string named Str.
? STR: Start with the cursor and look up a string named Str.
: N1,n2s/str1/str2/g:n1 and N2 are numbers, find str1 This string between the N1 line and N2 line, and replace the string with STR2

: 1, $s/str1/str2/g: look for the str1 string from the first line to the last line and replace the string with STR2

: 1, $s/str1/str2/gc: look for the str1 string from the first line to the last line, replace the string with str2, and confirm that the user is required to replace the

3, delete, copy and paste
X,X:X deletes one character for backwards, X deletes one character for forwarding
Nx:n as number, remove n characters for continuous backward
DD: Deletes the entire line where the cursor is located
Ndd:n is a number, starting at the cursor position, removing the down n column, such as 20DD, to delete the 20 columns.
YY: Copy the line where the cursor is located
Nyy:n is a number, the copy cursor is located in the down N line, such as 20yy is copied 20 rows
P,p:p Pastes the copied data to the next line of the cursor, and P is the line that sticks to the cursor.
U: Restoring previous action
"Ctrl" +r: Redo Previous action
.: decimal point, repeat the previous action, commonly used in repeated deletion, repeated paste.

4. Insert mode
I,i: Insert: Inserts the input text at the current cursor, and the existing text is back, where I inserts from the current cursor, I moves the cursor to the beginning of the current line, and then begins inserting.

A,A:A inserts the next character from the current cursor, and a is inserted at the last character of the line where the cursor is located

O,o: This is the case of the English letter O, O inserts a new row on the line next to the current cursor, O inserts a new row on the previous line at the current cursor.

R,r: Replace: R is the character that replaces the cursor, and R replaces the text of the cursor until the ESC key is pressed.

5, file operation related
: w: Saving files
: w filename: Save as FileName
: N1,n2 w filename!: Save N1 row to N2 row in filename
: n w FileName: Save nth line to filename
: L,. W FileName: Saves the current position of the cursor from the first line to the filename
:., $ w FileName: Saves the current position of the cursor to the end of the file in filename
: R filename: Open another file filename
: E FileName: Edit the new file filename instead of the original content
: F filename: Change the current file name to filename

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.