There are many different utilities in Linux, but some of them are used more often than others. For example, mv is a utility that allows you to change the name and location of a file/s and even move directories. Everything is just like in a graphical environment, but only through the command line.
How to move files?
To work with the utility, consider its syntax below; parentheses and <> signs are not used, but only show argument boundaries:
Let's imagine that logs have been accumulated on the device and it is necessary to move them to the /tmp/backup folder. For one file we will use the command:
As an analogue to this command, you can use the file descriptor command:
The alternative way more clearly reflects the logic of the process: the cat utility outputs the contents of a file, the > sign is a file descriptor that redirects the output to the target specified file. And the command rm log.txt removes files from the current directory. Which implements the move process. However, this method will not work for recursive moving of files or in other words all files from a folder. For this purpose in the mv command instead of the name of a specific file we will specify the mask *:
Expected result: all files from one directory will be moved to the target directory.
How to move directories?
The process is very similar to moving files, except now you need to specify a folder. This process is realised by the following command:
As a result, the backup_antivirus folder will be moved to /tmp/backup_all and the absolute or full path will look like this: /tmp/backup_all/backup_antivirus!