Linux Command Move Files


There are certain tasks that are done so often, users take for granted just how simple they are. But then, you migrate to a new platform and those same simple tasks begin to require a small portion of your brain's power to complete. One such task is moving files from one location to another. Sure, it's most often considered one of the more rudimentary actions to be done on a computer. When you move to the Linux platform, however, you may find yourself asking “Now, how do I move files?”
If you're familiar with Linux, you know there are always many routes to the same success. Moving files is no exception. You can opt for the power of the command line or the simplicity of the GUI – either way, you will get those files moved.
Let's examine just how you can move those files about. First we'll examine the command line.

mv source dest
mv /path/to/source /path/to/dest
In this example, move /home/vivek/data/ directory to /nas/home/vivek/archived/ directory:
$ mv /home/vivek/data/ /nas/home/vivek/archived/
OR
$ cd /home/vivek
$ mv data/ /nas/home/vivek/archived/

To get verbose output (explain what is being done), type:
$ mv -v /home/vivek/data/ /nas/home/vivek/archived/

How do I Move Multiple Directories?

Use the following syntax to move dir1 and dir2 to /path/to/dest/ directory:
$ mv -v dir1 dir2 /path/to/dest/
$ ls -l /path/to/dest/

OR use the following syntax:
$ mv -v /home/vivek/dir1/ /home/vivek/dir2/ -t /nas/home/vivek/archived/
mv /home/jack/testfile /home/jack/testfile2
or, if you're already within /home/jack:
mv testfile testfile2
mv /home/jack/testfile /home/jack/Documents/
mv ~/Downloads/*.mp3 ~/Music/

SHARE

About Unknown

    Blogger Comment
    Facebook Comment