Renaming and Moving Files in Bash 🔄
We talked about making and copying files and directories so far. But what if we wanted to rename something that we created?
Windows
💫 Renaming Files While in the Windows GUI, if you wanted to rename a file, we just right-click and rename. In the command line if we wanted to rename a file, we can use the mv
(move) command. It lets us rename files. Let's move the file without changing the directory that it's stored in. On my desktop here I have blue document
and I'm going to move or rename it to yellow document
. 🖥️ Now you can see that I have a yellow document
.
📁 Moving Files between Directories As you might guess, the mv
command also lets us move files from one directory to another. Let's move the yellow document
into my documents
directory and I can verify that, there it is. 🗂️ Cool. You can even move multiple files by using wildcards. Now you can see the rest of my colored documents went into my documents
directory. 📂
linux
🐧 Renaming and Moving Files in Linux
The exact same command can be used for Linux. mv
or move
can rename and move files and directories. Same thing applies here.
💫 Renaming Files I'm going to move my red document
and rename it to blue document
. 🖥️ Now we can see it's been renamed to blue document
.
📁 Moving Files between Directories Then I'm going to move the blue document
into the Documents
folder. 🗂️ There it is.
🗃️ Moving Multiple Files with Wildcards Using wildcards we can move multiple files at once, just like Windows. Let's move all that _document
files here to our Desktop. 🖥️ Now if we check the Desktop, there they are.
Last updated