Home  >  Article  >  Operation and Maintenance  >  How to make cp command overwrite without prompt in linux

How to make cp command overwrite without prompt in linux

WBOY
WBOYOriginal
2022-01-04 14:06:3911830browse

In Linux, you can use the "-f" parameter of the cp command to make the cp command overwrite without prompting. The cp command is used to copy files or directories, and the "-f" parameter is used to set overwriting of existing target files. Without giving a prompt, the syntax is "cp -f file".

How to make cp command overwrite without prompt in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to make the cp command overwrite without prompting in Linux

The Linux cp (English full spelling: copy file) command is mainly used to copy files or directories .

The syntax is:

cp [options] source dest

or

cp [options] source... directory

The parameters are as follows:

  • -a: This option is usually used when copying a directory , which preserves links, file attributes, and copies everything under the directory. Its effect is equal to the dpR parameter combination.

  • -d: Keep the link when copying. The links mentioned here are equivalent to shortcuts in Windows systems.

  • -f: Overwrite an existing target file without giving a prompt.

  • -i: Contrary to the -f option, a prompt is given before overwriting the target file, asking the user to confirm whether to overwrite. The target file will be overwritten when answering y.

  • -p: In addition to copying the contents of the file, the modification time and access permissions are also copied to the new file.

  • -r: If the given source file is a directory file, all subdirectories and files in the directory will be copied.

  • -l: Do not copy files, just generate link files.

When the parameter is -f, the target file will be overwritten and there will be no prompt.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to make cp command overwrite without prompt in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn