mkdir – make a whole set of directory, automatically if it does not exists

qtip-red


When organizing files, we often need to make a whole set of directories in order organize the files properly into directories. Most of the time, we will need to make a bunch of sub directories.


e.g.

cd /directory” then “mkdir leve1“, then “cd /directory/level1” then “mkdir level2“, then “cd /directory/level1/level2” then “mkdir level3” and etc… In fact, there is a parameter for mkdir to create the whole set of directory, automatically.



From the manual of mkdir

-p      Create intermediate directories as required.  If this option is
not specified, the full path prefix of each operand must already
exist.  On the other hand, with this option specified, no error
will be reported if a directory given as an operand already
exists.  Intermediate directories are created with permission
bits of rwxrwxrwx (0777) as modified by the current umask, plus
write and search permission for the owner.


It simply means just do a

mkdir -p /directory/level1/level2/level3

and it will create the directory “level1“, “level2” and “level3“.


Ciao !!!

More post - related

Please sponsor my coffee if you find my posts worth reading, thanks!

One Trackback

  1. By mkdir - StartTags.com on January 24, 2010 at 22:41

    [...] know how to use the mkdir command to create a new directory? Do I need a different FTP …mkdir make a whole set of directory, automatically if it …mkdir make a whole set of directory, automatically if it does not exists. When organizing files, we [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*
-->
Improve the web with Nofollow Reciprocity.