Note 10.2.1.
The History of Path Separators
Why is the path separator a
/ on Unix/Linux/MacOS systems and \ on Microsoft Windows systems? The concept of a hierarchy of folders was first developed in Unix. On a Unix command line a / is used to separate folder names in a file path and dashes are used to specify command line options, e.g., path/to/file/myfile -long -reverse.On a Windows system the
/ character is used for command line options, so the designers of Windows decided to use the \ for separating folder names in a file path, e.g., path\to\file\myfile /long /reverse.Using a
\ to separate folder names in a path is problematic because the \ character is also used as an escape character for special characters, such as \n for a new line character.Bottom line, we will always use the
/ character to separate folder names in a path, and even on Windows system the file path will work just fine.
