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