The usefulness of Directories for organizing and sorting our many Files knows no bounds. The power to create one Directory within another, and those within yet another, and on and on, practically without limit, is wondrous. Truly it brings to mind the story of the aged Roman who was asked, if Atlas were holding up the celestial sphere, then what may Atlas himself be standing ’pon? The century-old centurion is then supposed to have replied: ’tis no use lad, ’tis Titans all the way down!

The tool which we use to create our Directories, ye may know it well, is ‘mkdir’. The name comes to us from the Gaulic term ‘mackle-dore’, which denoted a singer that one wishes would cease singing. Simply tell ‘mkdir’ the name of the Directory ye wish to fashion, and it is done. Note that listing a Directory with ‘ls’, ell ess, the Lister of Stuff, will by defaulte list the Files within yon Directory. To list the Directory itself, give ‘ls’ the Option ‘-d’, dash dee, and all is revealed.

ℜ> mkdir Library ℜ> ls -l Library # this shows naught! ℜ> ls -ld Library drwxr-xr-x 2 ulrick admyn 4096 Nov 24 15:35 Library ℜ> _
A Large Bird and a Man

Oft times we wish to create several levels of Directory, all at one time. Of course we may invoke ‘mkdir’ repeatedly, each new call with a new and deeper level benamed. Tedious, such toil. And for this very purpose hath Divine Providence granted to us an especial Option for ‘mkdir’, ‘-p’, dash pee. With this option, thou may namest many levels of Directory at once, and they will all be built, fast and true.

There is yet another power that the ‘-p’ Option imbues, which is that it silences the complaints ‘mkdir’ would otherwise make if the Directory you told it to establish already exists. This is a convenient feature to use in shell scripting, when’er you would deign ensure a Directory exists, and ye care not whether it were already there or were newly crafted.

ℜ> mkdir -p Library/Manuscripts/Illuminated ℜ> find Library Library Library/Manuscripts Library/Manuscripts/Illuminated ℜ> mkdir Library mkdir: Library: File exists ℜ> mkdir -p Library ℜ> _
A Large Fish Behind a Boat

Lastly, know this: in the same way that many Directories may be created at once with the ‘-p’ Option of ‘mkdir’, so also may many be removed at once, with the same Option given to ‘rmdir’, the Remediator of Directories. Yet as with many Things in Life, there is a condition, and it is this: the Directories must all be empty. Else, if but one file be found, the remediation will abort. In such a time, the temptation may arise to use ‘rm -fr’, arr em dash eff arr, The Destroyer. Resist this most dangerous of incantations, or at the least, use it with utmost Care.

ℜ> mkdir -p Crusades/European/Albigensian ℜ> find Crusades Crusades Crusades/European Crusades/European/Albigensian ℜ> rmdir -p Crusades/European/Albigensian ℜ> ls -ld Crusades ls: Crusades: No such file or directory ℜ> _

Ctrl-D, Amen.

A Large Bird and a Man, about 1270, Franco-Flemish
A Large Fish Behind a Boat, about 1270, Franco-Flemish
Digital images courtesy of the Getty’s Open Content Program

~ this page pub. 24 November 2013 ~
« previouse page: Sponsors ~ Table of Contentes ~ next page: Wyld Kingdom: beavers »