Note: I originally wrote this in the late 1990s, when much of the software environment at my work still consisted of DOS and Windows-console applications, and supporting our staff frequently involved detailing command-line options for them. Unfortunately, about 15 years prior, Microsoft had decided to make mine and millions of others’ lives far more confusing by using a backslash character instead of a slash as a path separator, and I was forever having to explain the difference to folks.

Another 15 or 20 years later, while I don’t find myself explaining command-line arguments to people very frequently these days, I do still catch the occasional backslash outside its native habitat.


The slash character looks like this: / while a backslash looks like this: \.

Sometimes the slash is referred to as a forward slash to distinguish it from a backslash. However, the word slash by itself always refers to a forward slash, never a backslash.

How to remember which one is which? If you use a Western language and read from left-to-right, you can think of a little guy (we’ll call him Virgil) hopping along on his merry way down the street |||| until he hits a patch of ice and falls down.

  • If he falls forward /…! he becomes a forward slash (that is, a slash)
  • If he falls backward \…! he becomes a backslash

Just for a second, of course. Then he is flat on the ground and becomes an underscore (_).

Why does all of this matter? In the MS-DOS and Windows world, the backslash is used when you need to specify a file name that is in some kind of directory (folder) structure. Each directory name, plus the file name, is separated by a backslash.  In the so-called Universal Naming Convention (UNC), a server name begins with two backslashes. Some examples:

C:\My Documents\MyLetter.DOC
M:\Job666\Promotional Materials\Presentation.PPT
\\BIGSERVER\SHARED\REPORTS\Smith Company Final Report.DOC

This is the only, singular, unique, solitary, unitary purpose of the backslash.* In Windows, whenever you enter a filename, always use backslashes.

On the other hand, the slash (or forward slash) is used for everything else. In particular, it’s used to separate files and folder names in Unix-style paths and URLs:

/home/rcarduner/projects/cmdline/cmdline.asm
http://www.imdb.com

And back again in the Windows world, it’s often used to specify command-line arguments for various applications:

pkzip25 myzip.zip *.* /add /max /move
dir /s /w
net use m: /delete

It’s also frequently used to separate dates (12/31/1999), to indicate division or fractions (2-1/4), to indicate the joining (or separation) of two things into one (yin/yang, bondage/discipline), in abbreviations (w/o), and in the old English monetary system to separate the denominations of pounds, shillings, and pence (12£/3/6d). The backslash should never be used for any of these purposes.


*I realise that I did leave out at least one important use of the backslash, as an escape character in C-strings and many other languages (for example, to insert a linefeed, \n). But this note was originally written for non-developers and especially for folks that would have had no reason to ever see this abominable character if it hadn’t been for MS-DOS.