Linux CP operation, learn a little every day

Source: Internet
Author: User

Instruction name: CP (copy)
Features: Copy a file to another file or copy several files to another directory.
Syntax format:
CP [Options] Source Dest
CP [options] source ... directory
Common parameter Description:
-A as far as possible file status, permissions and other information are reproduced as original.
-R If the source contains a directory name, the files under the directory are also copied to the destination.
-F If a destination already has a file with the same file name, it should be deleted before copying.
Instruction Usage Example:
1. Copy the file AAA (already present) and name the BBB:
CP AAA BBB
2. Copy all C-language programs to the finished subdirectory:
CP *.c finished
3. Copy files from the specified directory to the current directory and rename

[email protected] root]# CP ~/.BASHRC Bashrc_bak

4. Force copying files from the specified directory to the current directory, regardless of whether the current directory contains the file

[Email protected] root]# cp-f ~/.BASHRC BASHRC

5. Copy the specified directory to the current directory

[Email protected] root]# cp-r/root/test.

[Email protected] root]# cp-r/root/test/.

As a result, when you copy a directory, the last level of the source path is copied all over, including itself.

6. Copy files from the specified directory to the specified directory

[email protected] root]# CP ~/.BASHRC/BAK/.BASHRC

7. Copy all the properties of the source file as you copy it. If you do not specify a parameter, the destination file may be inconsistent with the source file properties.

[Email protected] root]# cp-a ~/.BASHRC/BAK/.BASHRC

8. If two folders to ensure synchronization, one file changed, another file is changed, but to ensure that two files are up to date.

[Email protected] root]# cp-u/SRC/.BASHRC/BAK_SRC/BASHRC

Linux CP operation, learn a little every day

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.