• Illinois, USA

Moving files and folders in Linux: mv command

How do I move files in a Linux-based operating system using a bash terminal?

The syntax is very simple:

mv source target
mv source-directory target-directory

You can use a wildcard to move a number of files and folders using a single command. The asterisk is a wildcard character that represents all files and folders in the current directory. You can use this command to move all the files and folders from the current directory to the directory you will specify after the wildcard.

mv * here-is/the/new-directory/to-move-your-files/to

This is very useful if you want to move an entire group of files/folders from one location to another.

You also can select folders and change them to another specified location.

mv /dir/1 /dir/2 /dir/3 /target/path/here

mv can also be used to rename a file, as follows:

mv old-filename new-filename

 

Leave a Reply

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