mv
🧳
Moves/renames files or directories.
⚠️ Default behavior is to overwrite destination files.
Rename a single file
cd ~ && mv .bashrc .bashrc-renamed
Move a single file into a directory
cd ~ && mv .bashrc Documents
Note that the
Documents
directory should exist.
Move a single file onto a specific new path (filename)
cd ~ && mv .bashrc Documents/.bashrc-moved
Move a whole directory
mv my-src-dir ~/Documents/my-dest-dir
⚠️ Note that if
my-dest-dir
already exists,my-new-src
will be moved under it; i.e., you would have your files underDocuments/my-dest-dir/my-src-dir
Create backup for existing destination files -b
cd ~ && mv -b .bashrc Documents/.bashrc-moved
Move by wildcard selection -t
cd ~ && mv -t target-dir *.zip *.txt
Moves all
.zip
and.txt
files totarget-dir
directory.
Set to ask for overwriting -i
cd ~ && mv -i .bashrc Documents
Set to keep existing files (no overwrite) -n
cd ~ && mv -n .bashrc Documents
Top comments (0)