Email or username:

Password:

Forgot your password?
Simon Tatham

'mkdir -p' lets you make a deeply nested subdirectory like a/b/c/d, making all the intermediate directories on the way to it. So if even 'a' doesn't exist, it'll make that, then a/b, etc.

But you can also get it to make multiple _non_-nested directories, because it accepts '..' in the path and doesn't treat it specially:

$ mkdir -p alpha/../beta/../gamma
$ ls
alpha beta gamma
$

[Edit: to be clear, I'm pointing out an amusing edge case, not giving advice!]

3 comments
The Penguin of Evil

@simontatham That btw will blow up in interesting ways if one of them already exists and is a symlink 8)

ROTOPE~1 :yell:

@etchedpixels @simontatham I can never tell when .. means to pop the last directory in the path I used to get here, or it means to follow the literal ".." directory entry of wherever-the-hell-I-am-now.

Simon Tatham

@rotopenguin @etchedpixels yes, I've always hated the bash feature of 'helpfully' trying to interpret .. more like the naïve expectation, but only managing to do it for bash builtins, so that 'cd ../foo' and 'ls ../foo' are talking about different directories.

I do 'set -P' in my .bashrc, so that I get a consistent experience of .. going to the physical parent dir linked from my cwd's inode. I'd rather that than have to keep remembering which is which.

Go Up