Linux how to use cp command guide

  

Linux cp command usage is mainly used to copy files, plus parameters can also copy the directory, the following with the small series to understand the specific use of the cp command under Linux.

In general, shell will set up an alias when copying files, if the target file already exists, it will ask whether to overwrite the command line, regardless of whether you use the -i parameter. However, if cp is executed in a shell script, it will not be asked if it is overwritten without the -i parameter. This shows that the command line and shell scripts are executed in a different way.

1. Command Format:

Usage:

cp [options]. . . [-T] Source Purpose

or :cp [options]. . . source. . . Directory

or :cp [options]. . . -t directory source. . .

2. Command function:

Copy the source file to the target file or copy multiple source files to the target directory.

3. Command parameters:

-a, --archive is equal to -dR --preserve=all

--backup[=CONTROL Create a backup for each existing target file

-b is similar to --backup but does not accept arguments

--copy-contents in recursive processing is to copy special file contents

-d equals --no-dereference --preserve=links< Br>

-f, --force Remove the target file if it cannot be opened and try again (you don't need to select this option when the -n option

exists)

-i, --interactive Overwrite pre-inquiry (disable the previous -n option)

-H Follow the command line symbolic link in the source file

-l, --link link file Do not copy

-L, --dereference always follow symbolic links

-n, --no-clobber Do not overwrite existing files (make the previous -i option invalid)

-P, --no-dereference does not follow symbolic links in the source file

-p equals --preserve=mode, ownership, timestamp

--preserve[= List of attributes Hold the specified attribute (default: mode, ownership, timestamp), if

may maintain additional attributes: environment, link, xattr, etc.

-R, -r, --recursive copy directory And all the items in the directory
Previous12Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved