To move files or directories, you can use the mv command. It supports moving files or directories to another directory, and also supports regular matching.
mv [options] file /path/dir
mv [options] directory /path/dir
In the following example, we use the linux mv command to move test.txt to the /tmp directory.
➜ mv test.txt /tmp
In the above example, we use the mv command to move a file to another directory.
What if I want to move multiple files to other directories?
The mv command supports regular pattern matching to move multiple files to other directory.
In the following example, we use the mv command to move all the .log files in the current directory to the tmp directory.
➜ mv *.log /tmp
Moving directories with the mv command is similar to moving files.
In the following example, we move the newDirectoryName directory to the tmp directory.
➜ mv newDirectoryName /tmp
Use mv command to move multiple directories to other directories in batch
➜ mv dir_* /tmp
To move multiple files or directories, you can use regular pattern matching, as long as the conditions are met, they will be moved.
For more information about the mv command, you can check: man mv