Tuesday, 3 March 2015

Helpful command-line tips for Linux users part 5: working with directories - mkdir

list of all commands
explanation of the convention:
[] : values in square brackets are optional

mkdir BASIC USAGE 
mkdir [OPTION] DIRECTORY- make a new DIRECTORY

for example this will create a directory games in /home/ishtar/
> cd /home/ishtar
> mkdir games
this will do exactly the same, but when you're in a different dir.
> cd /
> mkdir /home/ishtar/games
Creating many directories in one go:
> cd /home/ishtar/games
~/games > ls
~/games >
~/games > mkdir mmos puzzle rpg strategy fps
~/games > ls 
fps  mmos  puzzle  rpg  strategy
As you can see this creates only one level of directories, but if you want to create a whole tree then that's possible as well with -p option:
~/games > mkdir -p mmos/screenshots/2015/wow
~/games > ls -R mmos/
mmos/:
screenshots

mmos/screenshots:
2015

mmos/screenshots/2015:
wow

mmos/screenshots/2015/wow:
as you can see if a directory exists (mmos) it will not get created, and no error will show up, the other directories are created.

No comments:

Post a Comment

Real Time Web Analytics