Copy Files in Linux with cp Command

Copy Files in Linux with cp Command


The cp command copies one or more files to become new, independent files. Syntax allows copying an existing file to a new file in the current or another directory, or copying multiple files into another directory. In any destination, new file names must be unique. If the new file name is not unique, the copy command will overwrite the existing file.

Copy Files in Linux with cp Command 1


When copying multiple files with one command, the last argument must be a directory. Copied files retain their original names in the new directory. Conflicting file names that exist at a destination may be overwritten. To protect users from accidentally overwriting directories with contents, multiple file cp commands ignore directories specifies as a source. Copying non-empty directories, with contents, requires the –r recursive option.

Linux File Copy


In the first cp command, Chapter1, Chapter2 failed to copy, but Sub.srt succeeded. Using the –r recursive option, copying Chapter1Chapter2  succeeded.

For more Details See Man Page




Tech info

Comments