To rename a file in Unix, you can use the mv
command.
For example, to rename the file oldname.txt
to newname.txt
, you can use the following command:
mv oldname.txt newname.txt
This will rename the file oldname.txt
to newname.txt
in the current directory.
You can also use the mv
command to move a file to a different directory at the same time as renaming it. For example, to rename the file oldname.txt
to newname.txt
and move it to the /tmp
directory, you can use the following command:
mv oldname.txt /tmp/newname.txt
This will move the file oldname.txt
to the /tmp
directory and rename it to newname.txt
.
Overall, the mv
command is a simple and powerful tool for renaming and moving files in Unix.