cp for filesystem
Copy files using uutils/coreutils cp.
Signature
> cp {flags} ...rest
Flags
-
--recursive, -r: Copy directories recursively. -
--no-dereference, -P: Copy symbolic links as symbolic links instead of their targets. -
--verbose, -v: Explicitly state what is being done. -
--force, -f: If an existing destination file cannot be opened, remove it and try again (this option is ignored when the -n option is also used). Currently not implemented for windows. -
--interactive, -i: Ask before overwriting files. -
--update, -u: Copy only when the SOURCE file is newer than the destination file or when the destination file is missing. -
--progress, -p: Display a progress bar. -
--no-clobber, -n: Do not overwrite an existing file. -
--preserve {list<string>}: Preserve only the specified attributes (empty list means no attributes preserved) if not specified only mode is preserved possible values: mode, ownership (unix only), timestamps, context, link, links, xattr. -
--debug: Explain how a file is copied. Implies -v. -
--all, -a: Copy hidden files if '*' is provided.
Parameters
-
...rest: Copy SRC file/s to DEST.
Input/output types:
| input | output |
|---|---|
| nothing | nothing |
Examples
Copy myfile to dir_b.
> cp myfile dir_b
Recursively copy dir_a to dir_b.
> cp -r dir_a dir_b
Recursively copy dir_a to dir_b, and print the feedbacks.
> cp -r -v dir_a dir_b
Move many files into a directory.
> cp *.txt dir_a
Copy only if source file is newer than target file.
> cp -u myfile newfile
Copy file preserving mode and timestamps attributes.
> cp --preserve [ mode timestamps ] myfile newfile
Copy file erasing all attributes.
> cp --preserve [] myfile newfile
Copy a symbolic link without copying the target.
> cp --no-dereference link-to-file newlink
Copy file to a directory three levels above its current location.
> cp myfile ....
Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/cp.html