“mkdir” command tips and tricks

Ion Utale
1 min readNov 14, 2021

--

the power of mkdir cli command

Create a normal directory ( folder )

mkdir myroot

this command will create a simple folder called “myroot

Create multiple directories at once

mkdir dir1 dir 2 dir3 

this command will create 3 directories “dir1”, “dir2”, “dir3

mkdir {dir1,dir2,dir3}

the same as the first one, but different syntax

if you want to create enumerated directories, you can use

mkdir dir{1..3}

and you can delete them with the cmd

rm -d dir{1..3}

Create a directory with the current date

mkdir `date ‘+%y%m%d’`

Basic but i think useful stuff

Now let’s create some parent directories.

To create parent directories like “myroot/project-name/src” you need to use the -p attribute like so:

mkdir -p myroot/project-name/src

yes that it! simple isn’t it?

Now we can combine many options:

mkdir -p `date '+%y%m%d'`/{1,2,3}

this command will create like so

20211114/1
/2
/3

That’s it for now

Let me know if you want to learn more tips and tricks from the terminal.

As always remember that you can clap more than once. Thank you

--

--