Linux cp command file directory copy


cp command is used for file directory replication. The cp command can copy one or more source files or directories to a specified destination file or directory. When copying multiple files at a time, the target file parameter must be an existing directory, otherwise an error will occur.

Syntax format
cp [parameter] [source file or directory] copy target cp [options] source dest cp [options] source... directory

-a: The effect of this parameter is the same as specifying the "-dpR" parameter. -d: When copying a symbolic link, the target file or directory is also established as a symbolic link and points to the source file or The original file or directory to which the directory is connected -f: Forcibly copy the file or directory, regardless of whether the target file or directory already exists -i: Ask the user before overwriting the existing file -l: Make a hard connection to the source file instead of copying the file - p: Keep the attributes of the source file or directory -R/r: Recursive processing, all files in the specified directory are processed together with the subdirectory -s: establish a symbolic link to the source file instead of copying the file -u: use this After the parameter is only copied when the change time of the source file is changed compared to the target file or when the target file corresponding to the name does not exist, the file-S: when the file is backed up, the file with the specified suffix "SUFFIX" instead of the file Default suffix -b: will overwrite existing file targets before Target file backup -v: Detailed operation of command execution


Copy all files in the current directory to the /tmp directory. The command is as follows:
cp -r .//tmp

Copyright © Windows knowledge All Rights Reserved