I was wondering about the difference between \
and /
in file paths. I have noticed that sometimes a path contains /
and sometimes it is with \
.
It would be great if anyone can explain when to use \
and /
.
I was wondering about the difference between \
and /
in file paths. I have noticed that sometimes a path contains /
and sometimes it is with \
.
It would be great if anyone can explain when to use \
and /
.
MS-DOS 1.0 retained the command line option (or switch) character convention of '/' from CP/M. At that time there was no directory structure in the file system and no conflict.
When Microsoft developed the more Unix like environment with MS-DOS (and PC-DOS) 2.0, they needed to represent the path separator using something that did not conflict with existing command line options. Internally, the system works equally well with either '/' or '\'. The command processor (and many applications) continued to use the '/' as a switch character.
A
CONFIG.SYS
entrySWITCHAR=-
could be used to override the/
default to improve Unix compatibility. This makes built in commands and standard utilities use the alternate character. The Unix path separator could then be unambiguously used for file and directory names. This entry was removed in later versions, but a DOS call was documented to set the value after booting.This was little used and most third-party tools remained unchanged. The confusion persists. Many ports of Unix tools retain the '-' switch character while some support both conventions.
The follow-on PowerShell command processor implements rigorous escaping and switch parameters and largely avoids the confusion except where legacy tools are used.