Thursday, 14 November 2013

mv - Rename (Move)

This command is used to move the file to some other location. This is also used to rename a file in the same location.
Syntax:
mv <source> <destination>
Ex:
mv F.txt ./A/B/
This will move the file F.txt to directory B inside directory A inside current directory.
mv *.txt ./A/B/
move all the text file to the same location as above.
mv ./A/B/*.txt ./
move back to the initial place from where it was moved as above.
mv –i <source> <destination>
it will ask before move the file to destination.
mv –f <source> <destination>
it will move without prompting even if it is overrating the existing destination.

Qs: what is the difference between cp and mv command?
By cp command source and destination both exist while source is vanished by mv command. After cp command i-node number of source and destination will be different while it remains same in case of mv. Modification time for destination file changes in cp but in mv it remains same.

No comments:

Post a Comment