how.wtf

How to move files in Linux

· Thomas Taylor

Moving files is an essential task individuals often need to perform.

The mv command and its usage

The mv command is used to rename or move files and directories from one location to another.

Basic syntax:

1> mv --help
2Usage: mv [OPTION]... [-T] SOURCE DEST
3  or:  mv [OPTION]... SOURCE... DIRECTORY
4  or:  mv [OPTION]... -t DIRECTORY SOURCE...`

The SOURCE can be one or many files / directories, and the DEST can be a single file or directory.

Moving multiple files to a directory

1mv file1 file2 dir1

Moving matching files to a directory

1mv *.md dir1

Moving a directory to another directory

1mv dir1 ~/Documents

Moving files without clobbering

Using the -i or --interactive option, mv will iteratively request user input for files with naming conflicts.

1> mv -i file1 ~/Documents
2mv: overwrite '~/Documents/file1'?

Renaming files

Rename file1 to file2:

1mv file1 file2

#Linux  

Reply to this post by email ↪