It annoys me having used Unix in college and now working on the Windows side. What's the history behind this decision? Anyone know why it worked out this way?

link|improve this question
People, if you feel like having a discussion, we have a new chatroom for it, but not here! Therefore, I removed all the previous comments – Ivo Flipse Aug 16 '10 at 15:37
feedback

4 Answers

up vote 17 down vote accepted

Unix introduced / as the directory separator sometime around 1970. I don't know why this character was chosen.

MS-DOS 2.0 introduced \ as the directory separator in the early 1980s. The reason / was not used is that MS-DOS 1.0 was already using / to introduce command-line options. It took this usage of / from CP/M, which took it from VMS.

/ it is recognized by most programmer-level APIs (in all versions of DOS and Windows). So you can often, but not always get away with using / as a directory separator under Windows. A notable exception is that you can't use / as a separator after the \\? prefix which (even in Windows 7) is the only way to specify a path using Unicode or containing more than 260 characters.

Many Windows programs just pass filenames through to the underlying API, so they support / and \ indifferently. In the command interpreter (in command.com or cmd), you can use / in many cases, but not always; this is partly dependent on the version of Windows (for example, cd /windows works recent versions but did not in Windows 9x).

(EDIT: corrected my assertion about the command interpreter; / often works)

link|improve this answer
/ is recognized as a directory separator by the MS-DOS or Windows command-line. – Tom Wijsman Aug 16 '10 at 14:05
1  
"C:\Windows\System32>cd /windows/system" works. – Andrew J. Brehm Aug 16 '10 at 14:11
@TomWij: Do you have a reference as to where precisely / is accepted on the command line? For example, what does dir /p do? and dir c:/p? and c:/windows/notepad.exe? and start /windows/notepad.exe? etc. (I don't have a Windows machine here to test.) – Gilles Aug 16 '10 at 14:25
msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx - File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections. - The command line uses this File I/O functions. – Tom Wijsman Aug 16 '10 at 14:28
@TomWij, @Gilles - please keep to the topic. Complaints about downvotes and related accusations/retaliations have nothing to do with the question. Downvotes happen, for good or bad reasons. If you really feel that something is wrong, take it to meta. – Gnoupi Aug 16 '10 at 15:44
show 1 more comment
feedback

The underlying Windows API can accept either the backslash or slash to separate directory and file components of a path, but the Microsoft convention is to use a backslash, and APIs that return paths put backslash in.

MS-DOS 2.0 copied the hierarchical file system from Unix and thus used the forward slash, but (possibly on the insistence of IBM) added the backslash to allow paths to be typed into the command shell while retaining compatibility with MS-DOS 1.0 and CP/M where the slash was the command-line option indicator.

Compare

dir/w

which shows the current directory in wide format against

dir\w

which runs the w file in the director dir.

References:

link|improve this answer
feedback

For what it is worth I am researching why Unix used /. Multics preceded Unix and it used >.

If I find out it will be some more useless trivia...

link|improve this answer
1  
According to one of the smartest Multicians I ever had the pleasure of working with; "As I recall, the Unix designers had already reserved the characters > and < to signify I/O redirection on the shell command line well before they had a multi-level file system. So when they got around to that, they had to find another character to signify pathname element separation." @CDT - Thanks. – dbasnett Aug 17 '10 at 15:19
feedback

They based it on the flawed letter-marks-the-volume DOS-style. Multiple aliases with absoutely no guarantee for coherency for directories in the My document feature is my pet pieve, though.

link|improve this answer
1  
The "flawed letter-marks-the-volume DOS-style" actually predates MS-DOS by several years. CP/M and later CP/M-86 both used it. They also used the "/" character as a "switch" character for command line options. The earliest versions of MS-DOS closely resembled CP/M-86 but quickly diverged. – BillP3rd Aug 16 '10 at 14:10
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.