Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

cp for filesystem

Copy files using uutils/coreutils cp.

Signature

> cp {flags} ...rest

Flags

  • --recursive, -r: copy directories recursively
  • --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

Parameters

  • ...rest: Copy SRC file/s to DEST.

Input/output types:

inputoutput
nothingnothing

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 file to a directory three levels above its current location

> cp myfile ....