Moving Files with mv
It's also possible to move files. For example, use mv ~/somefile /tmp/otherfile to move the file somefile to /tmp. The interesting part of this command is that it is not possible to predict exactly what will happen when using this command. If a subdirectory with the name otherfile exists in /tmp, somefile will be created in this subdirectory. If, however, no directory with this name exists in /tmp, the command will save the contents of the original file somefile under the new name otherfile in the directory /tmp. To prevent this behavior, use the -i option. This option causes mv to prompt you if a file of the same name exists in the target directory.
You can use mv to rename directories, regardless of whether those directories contain any files. If, for example, you need to rename the directory /somedir to /somethingelse, use mv /somedir /somethingelse.
Continue reading here: Viewing the Content of Text Files
Was this article helpful?