which one are you?

macOS/*BSD/#Linux/Unix: "/path/to/file"

Windows: "\path\To a Folder\file"

@nixCraft
ffs, what was this braindead "\path\To a Folder\file" sh!^ anyway?

@nixCraft Inaccurate for macOS. The Mac APIs use colons as directory separators. Yes, Darwin uses slashes, but those get translated to/from colons at the Darwin/Mac API interfaces.

Attempt to use a colon in a filename in the Finder and you will fail, but slashes are fine.

@clonezone @nixCraft Well, if Darwin and BSD and all its Unix roots uses "/" by default, what could the reason behind the colon?
@reinhart @clonezone @nixCraft The pre-OSX MacOS used them, but I’ve never seen them used in the modern OS.

@userid_required @reinhart @nixCraft They're there under the covers. Paths in the GUI have graphical elements between the components.

This was done, of course, for backwards compatibility with code written against pre-OS X versions of the Mac operating system.

Do a «touch foo:bar.txt», look at the file in Finder, and open it in TextEdit & look at the title bar.

@nixCraft Even Windows agrees that Unix is right. These days you can just use forward slashes in Windows.

@nixCraft

I use
"\/path\/to\/file"

@Ollivdb @nixCraft You are so wrong🔥
"/\path/\to/\file"
is the way.
@nixCraft and as a tree is confusing, MS-DOS has choosen to create a forest of up to 26 trees.

@nixCraft "\" will always be an escape character

also "\" is awkward to type quickly

@nixCraft although i will say file/folder name case-insensitivity is nice in windows.
@nixCraft forward slashes on both, as windows supports those for a very long while now. Not using backslashes also prevents accidental interpretation as escape characters.

@nixCraft

When you know far too much about Windows:
"\??\C:\Path\to A FoLdEr\nul"

@jkunkee @nixCraft I raise you to:

\??\C:\Path\to A FoLdEr\file:stream

@benbe @nixCraft

Realized I used the Ob prefix when I should've used the raw filename escape:

\\?\C:\Path\to A FoLdEr\COM1:stream

Ah, lovely alternate data streams. I got to fix wow64 redirection for them a while back. Very educational...

@jkunkee @nixCraft I was too lazy to look up the physical drive mapping since the DOS drive letters are internally just mappings onto the partition device IIRC …
@nixCraft An excellent way to memorize it. Well done!

@nixCraft
You're missing Mac which uses : as the path separator.

(Put a colon in a file name and then view it in finder.)

@nixCraft I wish I could choose, but I use both pretty much all day
@nixCraft Colons, brackets and dots.