
The version control method may be selected via the -backup option The backup suffix is '~', unless set with -suffix or SIMPLE_BACKUP_SUFFIX. The copy fails, or if -reflink= auto is specified, fall back to a standard copy. When -reflink is specified, perform a lightweight copy, where the data blocks are copied only when modified. Use -sparse= never to inhibit creation of sparse files. Specify -sparse= always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of version output version information and exitīy default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. Z, -context= CONTEXT set security context of copy to CONTEXT

x, -one-file-system stay on this file system u, -update copy only when the SOURCE file is newer than the destination file or when the destination file is missing T, -no-target-directory treat DEST as a normal file t, -target-directory= DIRECTORY copy all SOURCE arguments into DIRECTORY S, -suffix= SUFFIX override the usual backup suffix s, -symbolic-link make symbolic links instead of copying strip-trailing-slashes remove any trailing slashes from each SOURCE argument sparse= WHEN control creation of sparse files. remove-destination remove each existing destination file before attempting to open it (contrast with -force) R, -r, -recursive copy directories recursively
LINUX COPY DIRECTORY AND CONTENTS FULL
parents use full source file name under DIRECTORY c same as -preserve= context -no-preserve= ATTR_LIST don't preserve the specified attributes Preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all p same as -preserve= mode,ownership,timestamps P, -no-dereference never follow symbolic links in SOURCE n, -no-clobber do not overwrite an existing file (overrides a previous -i option) L, -dereference always follow symbolic links in SOURCE H follow command-line symbolic links in SOURCE i, -interactive prompt before overwrite (overrides a previous -n option) d same as -no-dereference -preserve= links -f, -force if an existing destination file cannot be opened, remove it and try again (redundant if the -n option is used) copy-contents copy contents of special files when recursive b like -backup but does not accept an argument Make a backup of each existing destination file a, -archive same as -dR -preserve= all -backup Mandatory arguments to long options are mandatory for short options too. Join the nixCraft community via RSS Feed, Email Newsletter or follow on Twitter.Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. He wrote more than 7k+ posts and helped numerous readers to master IT topics. Vivek Gite is the founder of nixCraft, the oldest running blog about Linux and open source. Simply use:įor more information see cp command man page by typing the following man command/ help command: Writing contents of a file to another file is easy in Linux.


-r : Recursive mode in Linux for cp command.copy all files and directories recursively Now, we can make changes in /home/vivek/project/ directory. Say you want to copy all files from /home/vivek/project/ to /home/vivek/backups/, run:Ĭp -av /home/vivek/project/ /home/vivek/backups/ To see cp command progress and verbose output, pass the -v command option to cp: Let us create a new file in Linux named foo.txt: 1 vivek vivek 6 Jan 20 18: 12 NIXCRAFT.txt Linux copy file to another file 1 vivek vivek 6 Jan 20 18: 12 nixcraft.txt
