ADVERTISEMENT

Linux Commands ❯ mv

mv

Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
syntax:

mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...
  • mv my_file1 my_dir1
    move my_file1 from the current directory to the directory my_dir1. If there is a file called my_file1 already exists in my_dir1, it will prompt for overwriting the same.
  • mv my_dir1 my_dir2
    move my_dir1 from the current directory to and existing directory my_dir2. my_dir1 will be renamed to my_dir2 if there is no existing directory called my_dir2
  • mv -f my_file1 my_dir1
    move my_file1 from the current directory to the directory my_dir1. If there is a file called my_file1 already exists in my_dir1, it will be overwritten without any prompting
  • mv -i my_file1 my_dir1
    move my_file1 from the current directory to the directory my_dir1. If there is a file called my_file1 already exists in my_dir1, it will prompt for overwriting the same.
  • mv -n my_file1 my_dir1
    move my_file1 from the current directory to the directory my_dir1. my_file1 will not be moved if there is a file called my_file1 already exists in my_dir1.
  • mv -t my_file1 my_dir1
    move my_file1 from the current directory to the directory my_dir1. If there is a file called my_file1 already exists in my_dir1, it will prompt for overwriting the same.
  • mv -T my_dir1 my_dir2
    rename my_dir1 to my_dir2. the contents of my_dir2 will be overwritten and renamed if it already exists
  • mv -u my_file1 my_dir1
    move my_file1 from the current directory to the directory my_dir1. the file will not be moved If there is a file called my_file1 already exists in my_dir1 newer than the source.