cp command
Table of Contents
cp command
https://www.geeksforgeeks.org/cp-command-linux-examples/
cp -R "/Volumes/SIGNATURE/folder1" "/Users/explorer436/Google Drive"
cp -R "/Volumes/SIGNATURE/folder2" "/Users/explorer436/Google Drive"
cp -R "/Volumes/SIGNATURE/folder3/folder4/folder5" "/Volumes/SIGNATURE"
In macOS, while you are using cp command to copy huge folders, to find out how much data is copied, go to Applications -> Utilities -> Activity Monitor -> Disk view. And look at the process name cp
Recursive copy
To copy a directory, including all its files and subdirectories, to another directory, enter (copy directories recursively):
$ cp -R * /home/explorer436/Downloads/destinationFolder
We might have to create destinationFolder before running this command
cp Src_file1 Src_file2 Src_file3 Dest_directory
Do not copy or overwrite existing files or folders
Modern versions of the `cp` command often have an option to prevent overwriting.
cp -rn source_dir/* dest_dir/
or, to also preserve attributes (like permissions, timestamps):
GNU cp (most Linux systems)
cp -arn source_dir/* dest_dir/
Standard POSIX cp (might work on macOS, other Unixes)
cp -prn source_dir/* dest_dir/
-r: Recursive, needed to copy directories and their contents.-n(--no-clobber): This is the key option. It tellscpnot to overwrite any existing file in the destination.-a(archive, GNU only): Preserves as much structure and attributes as possible (includes-dR --preserve=all, where-dis like--no-dereference --preserve=linksand-Ris recursive). It’s often simpler than specifying individual preservation flags.-p(preserve): Preserves mode, ownership, and timestamps (standard POSIX).source_dir/*: Selects all files and directories insidesource_dir. Be aware that this might not handle hidden files (starting with.) correctly depending on your shell settings, and can cause “Argument list too long” errors if you have a huge number of files.rsyncdoesn’t have these specific limitations.dest_dir/: The destination directory.