What is the difference between forward slashes and backslashes in paths?

9

Possible Duplicate:
Why does Windows use backslashes for paths and Unix forward slashes?

What is the main difference between forward slash (/) and backslash (\) in reference to paths, both remote and local?

If I recall correctly, backslash is used to denote something within the current computer or network such as C:\Windows or \\172.12.1.34, while forward slashes are used to denote something that is outside or external to the current computer or network such as http://www.google.com/.

I would like to know if this is an accurate explanation or if the difference is actually deeper than this, and the examples I gave are just coincidental.

Sean

Posted 2011-08-25T06:31:44.443

Reputation: 293

Question was closed 2011-08-25T12:47:34.160

3windows'' rest of world '/' – mic84 – 2011-08-25T06:53:53.950

1You really should read the answers that are already here, mic84. They already showed that that isn't true. – JdeBP – 2011-08-25T06:58:34.333

i dropped it in and tried to remove sorry, i've been sitting here with this page open thinking it was canceled sorry – mic84 – 2011-08-25T08:10:14.607

Answers

11

Unix and its variants have always used the forward slash (/) to denote filesystem hierarchy.

However, Windows owes its filesystem delimiter, the backslash (\), to its MS-DOS predecessor. And MS-DOS wasnt the originator of that. It was brought over from the QDOS operating system (which borrowed from CP/M), which MS bought and reworked into MS-DOS.

Since most, if not all, of web based protocols originated on UNIX (HTTP, FTP, etc.), Microsoft complies with those delimiters to keep compatibility.

Keltari

Posted 2011-08-25T06:31:44.443

Reputation: 57 019

1MS did not buy CP/M. MS bought QDOS (Quick and Dirty DOS), which was a simple clone of CP/M, and reworked that into MS-DOS. – Keith – 2011-08-25T06:45:04.377

@keith - u r correct. Fixed my answer. – Keltari – 2011-08-25T06:47:07.347

4

That's not an accurate explanation. The path separator is just a character, a token, that is somewhat arbitrary but usually chosen to mark a natural separation. The backslash as path separator comes from the lineage of CP/M, DOS, and Windows. The slash comes from Unix and possibly other systems before it.

The Internet URL path separator was chosen to be the slash since most of the developers of the standards where familiar with Unix. The Unix slash as path separator is usually considered to be the canonical separator. Its position on the keyboard also makes it easier to type for most people that have to enter it a lot.

Even cross platform scripting languages, such as Python, use the slash is the "normalized form" of specifying paths.

Keith

Posted 2011-08-25T06:31:44.443

Reputation: 7 263

1

Also notice DCL in VMS. Qualifiers are preceded by forward slashes, just as in Microsoft's command.

– JdeBP – 2011-08-25T07:11:35.730

2

At an implementation level, windows will handle '/' the same way as '\'. I would just use the '/'. It will make all you applications portable. MySQL and python also translates the '/' to what ever you need on your system, depending one what path separator they use.

The '\' is used in other areas like regular expressions, and some terminals and programming languages as an escape char. That will ensure the next char following it will be interpreted as a literal character, such as \n \r at the end of lines.

As far as notation regarding internal or external systems that is not actually true. The '/' was more popular early on with the *nix systems. Microsoft then become popular and now '\' is what people expect. But as I mentioned Microsoft has to be posix (posix a standard on how operating systems should operate) compliant which means that you could replace all the '\' with '/' in most places and every thing would work with out problems.

nelaaro

Posted 2011-08-25T06:31:44.443

Reputation: 9 321

0

Mostly it is just convention.

Windows seems to favor '\' while Linux and Unix seem to favor '/'

You can read in detail about paths and the various notations used on different systems on Wikipedia.

MaQleod

Posted 2011-08-25T06:31:44.443

Reputation: 12 560