Linux system to copy a folder to another folder

Linux system cp usage:

cp for copying files or directories.

Parameter Description:

-a: This option is typically used when copying a directory, it retains links, file properties, and copy all the contents of the directory. Its role is equal dpR parameter combinations.
-d: Reserved links when copied. Here's a link is a shortcut to Windows systems.
-f: overwrite the destination file already exists, without prompting.
-i: In contrast with the -f option, prompt before overwriting the destination file, ask the user to confirm whether to overwrite the answer target file will be overwritten when "y".
-p: In addition to copying the contents of the file, the time and also modify the access rights are also copied to the new file.
-r: If the source file is given a file directory, then copy all the subdirectories and files in this directory.
-l: do not copy the file, but the file is generated links.

Case 1:

cp flags.c flags_checkered.c
//复制 flags.c 到flags_checkered.c 文件,当前文件同属于同一目录下

Case 2:

cp -r /home/user05/lab07/* /home/user05/lab09
//复制 lab07文件夹下的所有文件到 lab09 文件夹下

Case 3:

cp flags.c /home/user05/lab09/flags_revised.c
//复制当前文件夹下的 flags.c 文件到 lab09 文件夹下flags_recised.c 文件

and many more.

Guess you like

Origin blog.csdn.net/weixin_44566432/article/details/93225868