• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Techgoeasy

Techgoeasy

Learn Oracle, PHP, HTML,CSS,Perl,UNIX shell scripts

  • Home
  • Oracle
    • Oracle database
    • Oracle Ebusiness Suite
    • Oracle weblogic
    • Oracle Performance Tuning
    • Oracle Hyperion
    • Oracle Cloud Tutorials
  • SQL
  • interview questions
  • Linux
  • PHP and HTML
  • Downloads
  • General
Home » Unix command and scripts » How to move a file/directory in Linux with Example

How to move a file/directory in Linux with Example

June 29, 2020 by techgoeasy Leave a Comment

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

Examples

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
linux mv command

You can get all the option of linux mv command using command

man mv
linux mv command

Hope you like explanation on Linux mv command. Please do provide the feedback so that it can improved

Also Reads

grep command in Linux : Grep command Means – globally search regular expression.grep command in unix is used for searching text,regular expression across multiple files
awk command in unix with examples :Awk command in Unix or Linux is a powerful command for processing text. Learn about awk syntax, records, fields, line Separator with examples of awk in unix
sed command in unix examples : sed command is a Stream Editor – works as a filter processing  input line by line And here are 32 Useful sed command examples in Linux/Unix
tee command in Unix : Check out about tee command in Unix,what options are available, how to append file using tee command, how to write to multiple files
RSYNC Command : RSYNC command – sync the data between two directory
https://en.wikipedia.org/wiki/Linux

Filed Under: Unix command and scripts

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



Subscribe to our mailing list

Enter your email address to subscribe to this blog and receive notifications of new posts by email

Recent Posts

  • How to check automatic statistics collection in Oracle
  • find segment name from block in oracle
  • How the sql query is executed in Oracle
  • How to do sql query tuning in Oracle
  • How to enable 10053 trace in Oracle

Copyright © 2023 : TechGoEasy

  • Hire me
  • Privacy Policy
  • Contact Us
  • New? Start Here
  • About Us