Permission to use : All the characters

Usage mode :cp [ -arf ] source dest / cp [ -arf ] source... Directory

effect : Copy one file to another ( File duplication ), Or copy multiple files to a directory

Be careful :

1. If the file already exists , When copying one file to another , There will be content coverage

2. If the file doesn't exist , When copying one file to another , A new file will be created

Key points :

1. precondition

(1)-a : Try to put the file status 、 Permission and other information are copied as they are

(2)-r : If source Contains the directory name , Then copy the directory and the documents under the directory to the destination in turn

(3)-f : If the destination already has the same file , Delete first, then copy

2.source : source address

3.dest / Directory : Destination address

Examples of use :

1. Let's say we have a file test.txt and test1.txt , Will file test.txt Copied to the test1.txt , There will be coverage

cp test.txt test1.txt

2. Suppose the file test.txt and test1.txt be located /usr/etc Next , Will now test.txt and test1.txt Copied to the /usr Under the table of contents , If there is a duplicate file , Delete first

cp -f test.txt test1.txt /usr/

3. Suppose the file test.txt and test1.txt be located /usr/etc Next , Will now /usr/etc Copy all files in the directory to /home Under the table of contents

cp /usr/etc/* /home

4. Add existing files test.txt , Now the file text.txt Copied to the test2.txt ( non-existent ) in , New files will be created test2.txt

cp test.txt test2.txt

summary :cp The command is used for file copying , The whole is called copy; There are two cases of file copying , One is the copy of a single file , The second is the copy of multiple files ; When a single file is copied , If the destination address file already exists, an override will occur , If the destination address file does not exist, a new file will be created ; When multiple files are copied , You can choose to copy multiple , You can also choose to copy the folder directly ; stay cp After the order -r when , If detected source It's a path , It will copy the folder and all the files under it to the destination address ;

Linux The road of command learning —— File copy :cp More articles about

  1. Linux The road of command learning —— Document rights management :chmod

    Permission to use : All the characters Usage mode :chmod [ -cfvR ] [ --help ] [ --version ] mode file... effect : This command is used in Linux Manage and change access to documents by roles in ...

  2. Linux The road of command learning —— Document connection creation :ln

    Permission to use : All the characters Usage mode :ln [ -options ] source target effect : Establish a connection between the source file and the target file Be careful : 1. Connection is divided into hard connection and soft connection , Hard connection can't make hard connection to directory , And not ...

  3. Linux The road of command learning —— Content clipping :cut

    Users : All the characters usage :cut [ -bcdfn ] [ --complement ] filename effect : Some fields in the intercepted file are used to display or store in a new file Application scenarios : 1. Content display : Intercept one or more ...

  4. Linux The road of command learning —— Change document owner :chown

    Permission to use :root user Usage mode :chown [ -cvfRh ] [ --help ] [ --version ] user[ :group ] file... effect : This command is used to change the owner of the document notes ...

  5. Linux The road of command learning —— Change the working directory :cd

    Permission to use : All the characters Usage mode :cd [ targetDir ] effect : This command is used in Linux Switch working directory in Be careful : 1.targetDir Represents the target directory , It can be represented by absolute path or relative path : 2. When tar ...

  6. Linux The road of command learning - Document browsing less

    Permission to use : All the characters Usage mode :less [ options ] filename effect : Document content browsing , You can browse the document forward or backward Be careful : 1.less Command and more The role of command is roughly the same ,less ...

  7. Linux Command learning

    Linux Command learning Ubuntu Common shortcut key •Ctrl+Alt+T: Open the terminal •Ctrl+Shift+T: New TAB •Tab: Command completion in terminal •Alt+ Numbers N: Switch to the second N Tabs •↑ ...

  8. Linux Command learning notes 1

    1.Linux Command learning 2.Mkdir /data       - Create folder   stay / Create folder  data 3.Cd               - Directory switching   Columns such as cd / 4.Touch /data/1 ...

  9. 《Linux Command learning manual 》 Series sharing column

    <Linux Command learning manual > Series sharing column <Linux Command learning manual > It has been arranged into PDF file , Click to download directly to local search https://www.webfalse.com/read/207 ...

Random recommendation

  1. 【.NET Deep breathing 】 Application context (AppContext)

    stay .net 4.6 A new class has been added to , It's called AppContext, This guy , The technical content is not high , It's just convenient to use when programming . The application context allows you to define an identity ( Represented by string ), And it can be switched during the running of the application ...

  2. navicat Shortcut key

    ctrl+R.N Run window sql ctrl+shift+r Run selection sql ctr+q open windows ctrl+/   |ctrl+shift+/ notes    | relieve ctrl+L Delete a line ctr ...

  3. Digests from CG articales

    Turtle Talk Prior to the on-set motion capture, the team had the actors perform expressions while be ...

  4. ORLEANS REMOTE DEPLOYMENT

    Orleans Remote Deployment Table of Contents Overview: 1 Prerequisites. 2 Deployment Steps. 2 Orleans ...

  5. Software engineering in class homework —— seek “ Buckets ”(C++)

    One . design idea The idea is similar to looking for a water king , This time it's just that the counters and variables are set to arrays . One at a time ID Compared with three suspects , If they are the same, count them : If all three are different , Then all three counters are subtracted by one . If reduced to 0, Then assign a new value to the suspect . Two . ...

  6. BZOJ 1043 HAOI2008 The falling disc Computational geometry

    The main idea of the topic :n Two disks fall in turn . Find the area of the contour line you can finally see I'm against ! Let's get together ! Drive away the plate ! Cough . It's a wonderful question Today I went to read the explanation and the white book -- First, we do it backwards For each disc, process out after it ...

  7. Use Win32 API Create irregular shapes &amp; Windows with transparent colors

    I suddenly thought of 9 The two-sided problem in the internship of a company , It's about how to use it Win32 API Achieve a transparent window , At that time, my brain damage answer must have made the interviewer laugh and cry . So I decided to study this problem . After an afternoon of groping , basic ...

  8. Wiki: HSL and HSV Color space

    HSL and HSV( It's also called HSB) It's right RGB Two related expressions of the point in color space , They try to describe more than RGB More accurate perception of color connections , It is still simple in calculation .HSL Express hue( Hue ).saturation( ...

  9. Creator Imitation super Mary game source code sharing

    Creator Imitation super Mary game source code sharing I used to use Cocos Creator Do a super Mary imitation of the game , The version used is 14.2 , It can be packaged as APK, Now bisher has finished , Share the game , Let's learn and improve together . special ...

  10. Xianfeng Lightweight Java Middleware platform : Attribute management 、 Dictionary management

    Attribute management : The main function is to maintain some system defined . Business defined attribute data , As for what attributes are , Simply put, it's made up of keys key And the value value The composition of the data , The property query list page is as follows : The form realizes the function of direct editing Dictionary management : The main function is to maintain one ...