How To Rename A File In Linux
Shorter post today — I wanted to share how to rename a file in Linux.
This post is also on my website!
Introduction
Renaming files in Linux isn’t really a thing. You don’t directly rename a file like you do in Windows.
Instead, you move the file and simply provide a new name.
How To Rename A File In Linux
So to rename a file in Linux, you can use the move (mv) command. You can see an example of this below:
mv /dir/old-filename.txt /dir/new-filename.txt
That’s it!
How To Rename A Dir In Linux
If you want to know how to rename a directory in Linux — you can use the below example:
mv /dir/old-dir /dir/new-dir
Since we are still using the mv command, you can use the same options below.
Move Command Options
The move command also has a number of options — I will leave these below:
- -i : This stands for interactive and it is used to prompt the user prior to overwriting the existing file
- -u : This stands for update and it’s used to only move the file if the source…