"Linux" basic daily life CUT&MV&SCP command

Source: Internet
Author: User
Tags file copy scp command secure copy

The Cut command is used to display the text from the beginning of NUM1 to num2 for each line

Grammar:
Cut [-bn] [file]
Cut [-c] [file]
Cut [-DF] [file]

Instructions for use:
The cut command cuts bytes, characters, and fields from each line of the file and writes those bytes, characters, and fields to standard output.
If you do not specify a File parameter, the Cut command reads standard input. One of the-B,-C, or-f flags must be specified.

Parameters:
-B: Split in bytes. These byte locations will ignore multibyte character boundaries unless the-n flag is also specified.
-C: Split in characters.
-D: Custom delimiter, default is tab.
-F: Used with-D to specify which area to display.
-N: Cancels splitting multibyte characters. Used only with the-B flag. If the last byte of the character falls on the List parameter indicated by the-B flag
Range, the character is written out; otherwise, the character is excluded.

Instance:
When you execute the WHO command, you will output something like this:
$ who
rocrocket:0 2009-01-08 11:07
Rocrocket pts/0 2009-01-08 11:23 (: 0.0)
Rocrocket pts/1 2009-01-08 14:15 (: 0.0)

1. If we want to extract the 3rd byte of each row, that's it.
W.H.O. | Cut-b 3

2. If you extract the third character of each line
W.H.O. | Cut-c 3

3. Remove the last point as shown below
10.32.204.22.

Cut-d "." 1,2,3,4

The MV command is used to rename a file or directory, or to move a file or directory into another location.

Parameters:
-I: Ask if you want to overwrite
-F: Forced override

If you move all files and directories under/usr/student to the current directory, the command behavior:
mv/usr/student/*.

The SCP command is used to copy files and directories between Linux.

The abbreviation for secure copy, SCP is a secure remote file Copy command under the Linux system based on SSH login.

Instance:
1. Copy from local to remote

Command format:
SCP Local_file [Email Protected]_ip:remote_folder
Or
SCP Local_file [Email protected]_ip:remote_file
Or
SCP Local_file Remote_ip:remote_folder
Or
SCP Local_file Remote_ip:remote_file

1th, 2 Specify the user name, command execution after the need to enter the password, the 1th only specifies the remote directory, the file name is unchanged, 2nd specified the file name;
3rd, 4 does not specify a user name, command execution after the need to enter a user name and password, the 3rd only specifies the remote directory, the file name is unchanged, 4th specified the file name;

Application Examples:
Scp/home/space/music/1.mp3 [Email Protected]:/home/root/others/music
Scp/home/space/music/1.mp3 [Email Protected]:/home/root/others/music/001.mp3
Scp/home/space/music/1.mp3 Www.runoob.com:/home/root/others/music
Scp/home/space/music/1.mp3 Www.runoob.com:/home/root/others/music/001.mp3

Copy Directory command format:
Scp-r Local_folder [email protected]_ip:remote_folder (used)
Or
Scp-r Local_folder Remote_ip:remote_folder
The 1th one specifies the user name, the command executes after the need to enter the password;
The 2nd does not specify a user name, the command will need to enter the user name and password after execution;

Application Examples:
Scp-r/home/space/music/[Email protected]:/home/root/others/
Scp-r/home/space/music/www.runoob.com:/home/root/others/

The above command copies the local music directory to the remote others directory.

2. Copy from remote to local

From remote replication to local, as long as the following 2 parameter exchange order is copied from the local copy to the remote command, the following example

Application Examples:
SCP [Email Protected]:/home/root/others/music/home/space/music/1.mp3
Scp-r www.runoob.com:/home/root/others//home/space/music/

Description

1. If the remote server firewall has the specified port set for the SCP command, we need to use the-p parameter to set the port number of the command, as follows:
# # # #scp Command use port number 4588
Scp-p 4588 [Email protected]:/usr/local/sin.sh/home/administrator

2. Use the SCP command to ensure that the user you are using has permission to read the appropriate files for the remote server, otherwise the SCP command will not work.

Learn to organize http://www.runoob.com/linux/linux-command-manual.html

"Linux" basic daily life CUT&MV&SCP command

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.