On this page you find all important commands for the CLI tool cp. If the
command you are looking for is missing please ask our AI.
cp
The cp
command, short for "copy," is a command line tool available on Unix-like operating systems such as Linux and macOS. It is used to copy files and directories from one location to another. The basic syntax of the cp
command is as follows: cp [options] source destination
Here, source
represents the file or directory to be copied, while destination
denotes the target location where the copied file or directory should reside. Some common options that can be used with the cp
command include: - -r
or -R
: Used to copy directories recursively (including all subdirectories and files within).
-i
: Enables interactive mode, prompting the user before overwriting existing files.-v
: Enables verbose mode, displaying informative messages about the copying process.-p
: Preserves the original file attributes (such as timestamps and permissions) of the copied files. For example, to copy a file namedfile.txt
from the current directory to the/path/to/destination/
directory, you would use the following command:cp file.txt /path/to/destination/
Similarly, to copy a directory namedfolder
and all its contents recursively to the/path/to/destination/
directory, you would use the following command:cp -R folder /path/to/destination/
Thecp
command is a versatile tool for copying files and directories, and it is widely used for various file management tasks in command line environments.
List of commands for cp:
-
cp:tldr:0547c cp: Follow symbolic links before copying.$ cp -L ${link} ${path-to-target_directory}try on your machineexplain this command
-
cp:tldr:19459 cp: Recursively copy a directory's contents to another location (if the destination exists, the directory is copied inside it).$ cp -R ${path-to-source_directory} ${path-to-target_directory}try on your machineexplain this command
-
cp:tldr:2ba61 cp: Use the full path of source files, creating any missing intermediate directories when copying.$ cp --parents ${source-filename} ${path-to-target_file}try on your machineexplain this command
-
cp:tldr:54f2c cp: Recursively copy a directory's contents to another location (if the destination exists, the directory is copied inside it).$ cp -r ${path-to-source_directory} ${path-to-target_directory}try on your machineexplain this command
-
cp:tldr:58608 cp: Copy a file to another location.$ cp ${path-to-source_file-ext} ${path-to-target_file-ext}try on your machineexplain this command
-
cp:tldr:5af7e cp: Copy a directory recursively, in verbose mode (shows files as they are copied).$ cp -vR ${path-to-source_directory} ${path-to-target_directory}try on your machineexplain this command
-
cp:tldr:6769a cp: Copy a directory recursively, in verbose mode (shows files as they are copied).$ cp -vr ${path-to-source_directory} ${path-to-target_directory}try on your machineexplain this command
-
cp:tldr:c9b64 cp: Copy text files to another location, in interactive mode (prompts user before overwriting).$ cp -i ${*-txt} ${path-to-target_directory}try on your machineexplain this command
-
cp:tldr:d49e4 cp: Copy multiple files at once to a directory.$ cp -t ${path-to-destination_directory} ${filename1 filename2 ---}try on your machineexplain this command