mv

For filesystem.

Move files or directories using uutils/coreutils mv.

Command Type

built-in

Signature

> mv {flags} ...rest

Flags

  • --force, -f: Do not prompt before overwriting.
  • --verbose, -v: Explain what is being done.
  • --progress, -p: Display a progress bar.
  • --interactive, -i: Prompt before overwriting.
  • --update, -u: Move and overwrite only when the SOURCE file is newer than the destination file or when the destination file is missing.
  • --no-clobber, -n: Do not overwrite an existing file.
  • --all, -a: Move hidden files if ’*’ is provided.

Parameters

  • ...rest: Rename SRC to DST, or move SRC to DIR.

Input/output types:

input output
nothing table<source: string, destination: string, message: string>
nothing nothing

Examples

Rename a file.

> mv before.txt after.txt

Move a file into a directory.

> mv test.txt my/subdirectory

Move only if source file is newer than target file.

> mv -u new/test.txt old/

Move many files into a directory.

> mv *.txt my/subdirectory

Move a file into the “my” directory two levels up in the directory tree.

> mv test.txt .../my/

Move a file and show what is being done.

> mv -v before.txt after.txt
╭───┬────────────┬─────────────┬──────────╮
│ # │   source   │ destination │ message  │
├───┼────────────┼─────────────┼──────────┤
│ 0 │ before.txt │ after.txt   │ renamed  │
╰───┴────────────┴─────────────┴──────────╯

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.