We can move file or directory from one location to another location in Linux using mv command . This command can also be used to rename the file or directory also.This is a quite a useful command.
mv – move files(s) /dirs
|Options: – |
-f mv will move the file(s) without prompting even if it is writing over an existing target.
-i mv will prompt for confirmation whenever the move would overwrite an existing target-b mv will take backup before overwriting
-n mv will not overwrite the file if it exists
moves f1.txt to f2.txt, if f2.txt exists prompts for confirmation mv –i f1.txt f2.txt moves f1.txt to f2.txt, if f2.txt exists ,it just overwrite without prompting mv –f f1.txt f2.txt moves f1.txt to f2.txt, if f2.txt exists ,then backup is taken mv -b f1.txt f2.txt moves f1.txt to f2.txt, if f2.txt exists ,then backup is taken with suffix .bak mv -b --suffix=.bak f1.txt f2.txt moves f1.txt to f2.txt, if f2.txt exists ,move does not happen mv -n f1.txt f2.txt move file1 to dest directory mv file1 dest moves file1 to 3 to dst_directory mv file1 file2 file3 dest_directory moves directory app and all its subdirectories files to /u000 directory mv app /u000 moves f1.txt to f2.txt in the directory oracle mv f1.txt oracle/f2.txt
You can get all the option of linux mv command using command
Hope you like explanation on Linux mv command. Please do provide the feedback so that it can improved