What is the difference in using a forward slash and backslash in navigating file systems. Also what is the difference between ./
and ../
?

- 730,956
- 141
- 904
- 1,278

- 3,163
- 11
- 36
- 47
-
http://www.howtogeek.com/181774/why-windows-uses-backslashes-and-everything-else-uses-forward-slashes/ – Jonathan May 08 '15 at 13:05
-
Did you try googling for the question title? This is trivial to find an answer to on the internet currently. – Jonathan Cast Jul 18 '16 at 18:42
-
Excellent answer wrt. MS/Windows on dupe question:http://stackoverflow.com/a/38428899/321013 – Martin Ba Jul 18 '16 at 20:39
-
2Question asked 4 years ago cannot be a duplicate of one asked yesterday. Sorry! Try Again? – Jul 19 '16 at 14:34
-
@nocomprende Which question is marked "duplicate" is usually determined by which question has better answers. – Moshe Katz Jul 19 '16 at 19:45
-
2@MosheKatz so, merge them? One question, best answers. Done. – Jul 20 '16 at 13:06
4 Answers
Well, in most languages backslashes need to be escaped in string literals, slashes do not. Further backslashes only work on Windows, while slashes work pretty much everywhere.
On the other hand, when passing path names as arguments to Windows programs, using slashes might not work because many Windows programs use slashes to signify command line flags, so you need to use backslashes.
On .
vs. ..
: .
is the current directory, ..
is the parent directory.

- 30,738
- 21
- 105
- 131

- 363,768
- 54
- 674
- 675
Microsoft operating systems (e.g. DOS and Windows) use backslashes (\), UNIX-based operating systems (e.g. Linux) use slashes (/).
The dot (.) means the current working directory, it's like saying "here". The double dot (..) means the parent directory.

- 424
- 1
- 5
- 18
-
1just a sidenote: modern windows boxes also support the "/", i.e: cd / – marcelog Aug 04 '11 at 18:43
-
You can use slashes in Windows path names as well (most of the time anyway). – sepp2k Aug 04 '11 at 18:44
The difference between slash and backslash in Windows are from my tests at least non-existing, but I believe that in earlier editions they used backslash. UNIX systems uses slash.
The difference between ./
and ../
is that ./
represents the position in the hierarchy where you are standing while ../
is the parent directory.

- 30,738
- 21
- 105
- 131

- 17,816
- 1
- 22
- 21
Backslash is used for:
File names in DOS and Windows, e.g. D:\documents\office, C:\java\jdk escape sequences in C, Unix, and other languages/systems that borrow the same syntax (C++, Java, etc.). For example, \n means newline and \t means tab.
Forward slash is used for:
- File names on Unix (and Mac OS X, since it is derived from Unix), e.g.
/cs/student/jsmith/cs8/lab00
,/Users/Shared/cs8/cTurtle.py
. - Web addresses (URLs), such as
http://www.cs.ucsb.edu/~pconrad/cs8
. - Dividing in many programming languages, e.g. battingAvg = hits / atBats;

- 30,738
- 21
- 105
- 131

- 352
- 2
- 8