There are many commands under Linux, one of which has problems with me using it all the time, that is, the CP command. Every time you use this command, you will prompt a cp:omitting directory error. Finally, I found out that the CP command needs to be followed by command parameters when copying the directory of the CP command. No wonder I reported an error as soon as I used the cp command. Here are some tips for using this command:
1. cp command syntax
cp [options] <source file or directory> <target file or directory> or cp [options] source1 source2 ... directory
The syntax in the previous section is a single file or directory copy, the latter is a copy of multiple files to the last directory. The options parameters include:
- a retains link and file attributes, recursively copy the directory, which is equivalent to the following combination of three options d, p, and r.
- d Keep the link when copying.
- f Delete the target file already exists without prompting.
- i A confirmation prompt will be given before overwriting the target file, which is an interactive copy.
- p After copying the contents of the source file, the modification time and access permissions will also be copied to the new file.
- r If the source file is a directory file, CP will recursively copy all subdirectories and files in that directory. Of course, the target file must be a directory name.
- l No copying, just linking files.
-s Copy into symbolic link file (symbolic link), that is, the "shortcut" file;
-u If destination is older than source, destination will be updated.
2. Usage examples
I started using the command cp file ./direct. This command can be used normally, but when using cp direct ./direct2 later, it is reported to cp: omitting directory.
The copying of directory to directory is used by cp -r dict dict2; if all files and folders in the directory are copied to the dict2 directory, you can use the command cp -r dict/* dict2 to achieve it.
Copy file to file (operating in the same directory, equivalent to backup and rename) cp -i file1 file2 or cp file1 file2
At present, I still have such low-level errors, which means I am still not familiar with the commands. Alas, I will learn more linux commands in the future.
The above is an explanation of the use of the Linux copy file command CP introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!