Linux uses CP to copy files or directories

Time:2021-3-6

usage method:

$ cp --help
Usage: CP [option]... Source file target file
 Or: CP [option]... Source file... Directory
Copy the source file to the target file, or copy multiple source files to the target directory.

The parameters that long options must use are also required for short options.
  -A is equivalent to - PDR
  -D if the source file is a soft connection file, copy the soft connection instead of the file itself
  -p. -- preserve [= attribute list] keeps the specified attribute (default: mode, ownership, timestamp)
  -r. - R, - recursive recursively copies all the contents of a directory and its subdirectories
  -v. -- verb displays the copy process

Use example:

#Copy file to directory
cp file1 /tmp/

#Copy file to directory并重命名
cp file1 /tmp/test1

#Recursively copy directory contents to another directory
cp -r dir1/ /tmp/

#Recursively copy directory contents to another directory
cp -r dir1/ /tmp/dir2

#Copy file to directory并保留原文件的属性信息
cp -p /home/user1/file1 /tmp/

#Recursively copy directory contents to another directory并保留原文件的属性信息
cp -pr /home/user1/dir1/ /tmp/

#Copy the file to another directory and keep the attribute information of the original file
cp -a /home/user1/file1 /tmp/

#Recursively copy directory contents to another directory并保留原文件的属性信息
cp -a /home/user1/dir1/ /tmp/

#Recursively copy directory contents to another directory并显示复制过程
cp -r -v /home/user1/dir1/ /tmp/

Recommended Today

Rust programming video tutorial (Advanced) – 024_ 3 syntax of all modes 3

Video address Headline address:https://www.ixigua.com/i677586170644791348…Station B address:https://www.bilibili.com/video/av81202308/ Source address GitHub address:https://github.com/anonymousGiga/learn_rus… Explanation content 1. Ignore values in mode(1) Use_ Ignore entire valueexample: fn foo(_: i32, y: i32) { println!(“This code only uses the y parameter: {}”, y); } fn main() { foo(3, 4); } Note: placeholders are used for parameters in the function, mainly when implementing […]