In this Blog, we will learn how we can use mv command in Linux.
mv command is used to move files and directories.
First of all open Terminal, Ctrl+Alt+t .
Syntax for mv command is:
mv [options] [source] [Destination]
One more feature or say use of mv command is to change directory name and rename files.
So, lets see how we can do this:
In above example we had changed file name text1.txt to text2.txt and the content of the file remains same as it is.
Now, if you want to move a file into a particular directory then we will use command as:
mv [File_name] [Directory_name]
You can see that previously dir1 contains only text1.txt file after that we can see that in that directory another file get moved text2.txt.
As we already know dir1 contains text1.txt and text2.txt files and if we try to move a file whose name is same as text2.txt which is already present in that directory then it will overwrite the contain of that file as we seen in previous blog, To avoid such type of condition we will use one option i.e., -i
mv -i [Source] [Destination]
Here -i means interactive which will ask before overwriting the content.
If you type y and enter than the content will get overwritten and if we type n and enter then content will not be overwritten.
For move options you can try man command as:
man mv
For any query and suggestions you may contact with me or you may put comment in comment box.
Thank You.
Contact Details:
Phone: +91-8208826234
E-mail: shivampawar1038@gmail.com
mv command is used to move files and directories.
First of all open Terminal, Ctrl+Alt+t .
Syntax for mv command is:
mv [options] [source] [Destination]
One more feature or say use of mv command is to change directory name and rename files.
So, lets see how we can do this:
In above example we had changed file name text1.txt to text2.txt and the content of the file remains same as it is.
Now, if you want to move a file into a particular directory then we will use command as:
mv [File_name] [Directory_name]
You can see that previously dir1 contains only text1.txt file after that we can see that in that directory another file get moved text2.txt.
As we already know dir1 contains text1.txt and text2.txt files and if we try to move a file whose name is same as text2.txt which is already present in that directory then it will overwrite the contain of that file as we seen in previous blog, To avoid such type of condition we will use one option i.e., -i
mv -i [Source] [Destination]
Here -i means interactive which will ask before overwriting the content.
If you type y and enter than the content will get overwritten and if we type n and enter then content will not be overwritten.
For move options you can try man command as:
man mv
For any query and suggestions you may contact with me or you may put comment in comment box.
Thank You.
Contact Details:
Phone: +91-8208826234
E-mail: shivampawar1038@gmail.com
Nice one
ReplyDeleteThank You.
Delete