[Linux command] mv command option list [Must-see for beginners]

[Linux command] mv command option list [Must-see for beginners]

Summary Linux command list

What is the mv command?

A command for moving files and directories. "mv" is an abbreviation for "move".

How to use mv command

/home/hoge


$mv move source move destination

List of options for mv command

option Description
-b Back up files that will be overwritten or deleted
-f Overwrite without confirmation
-i Confirm in case of overwriting
-n Do not move if there is a file or directory with the same name in the move destination
-u Overwrite only if the move source is newer
-v View detailed information about the move

-b option

The mv command basically overwrites, so if you add the -b option, it will back up the overwritten file.

Behavior when there is no option

/home/hoge/test


$ ls
test.txt ex.txt test.log

$ mv test.txt ex.txt

$ ex.txt test.log

Behavior when the -b option is attached

/home/hoge/test


$ ls
test.txt ex.txt test.log

$ mv -b test.txt ex.txt

$ ex.txt~ ex.txt test.log

Backup files have "~" after the file name.

-v option

It displays detailed information about the move. It is often used for checking when multiple files are moved.

/home/hoge/test


$ ls
test.txt ex.txt test.log

$ mv -v test.txt ex.txt test.log test2
`test.txt' -> `test2/test.txt'
`ex.txt' -> `test2/ex.txt'
`test.log' -> `test2/test.log'

$ ls

$ cd ../test2

$ ls
test.txt ex.txt test.log

Use as rename

mv command test.txt in the test directory You can navigate to it in the test2 directory with the name test2.txt.

/home/hoge/test2


$ ls

$ cd ../test

$ mv test.txt test2/test2.txt

$ cd ../test2

$ ls
test2.txt

Of course, it can be used as rename even in the same directory.

Why it can be used as a rename And why can the mv command move in an instant even with a large capacity of 1G? These two are actually interesting to look at the source of the mv command, so I will write them in another article.

List of options for other Linux commands

pwd, mkdir, cd , cat, cp, ls, touch, less, mv, rm, ssh, man, ** Adding at any time **

Advertising space

We undertake various development and construction contracts and mentor work for beginners. If you are interested, please go to ** here **

Recommended Posts

[Linux command] mv command option list [Must-see for beginners]
[Linux command] cp command option list [Must-see for beginners]
[Linux command] ls command option list [Must-see for beginners]
[Linux command] less command option list [Must-see for beginners]
[Linux command] cat command option list [Must-see for beginners]
[Linux command] pwd command option list [Must-see for beginners]
[Linux command] rm command option list [Must-see for beginners]
[Linux command] cd command option list [Must-see for beginners]
[Linux command] man command option list [Must-see for beginners]
[Linux command] ssh command option list [Must-see for beginners]
[Linux command] mkdir command option list [Must-see for beginners]
[Linux command summary] Command list [Must-see for beginners]
Linux command memorandum [for beginners]
[Must-see for beginners] Basics of Linux
Linux command list
Linux operation for beginners Basic command summary
Linux command for self-collection
What is Linux? [Command list]
Linux distribution recommended for beginners
Linux Command Dictionary (for myself)
Python #list for super beginners
Convenient Linux shortcuts (for beginners)
Frequently used Linux commands (for beginners)
Linux command # 4
Linux command # 5
mv command
How to create a shortcut command for LINUX
linux at command
[Linux] Search command
Roadmap for beginners
Linux [directory command]
Linux server command
Linux Command Summary
[Basic] linux command
Linux [shell command]
[Linux] Command / Knowledge
pyenv for linux
My linux command
Linux command <Basic 1>
Linux command collection
Linux mkdir command
Linux command basics
[Linux] Git command
Linux (command memory)
[For beginners] How to use say command in python!
[Linux] Basics of authority setting by chmod for beginners