Console: Difference between paths

1

1

Please explain me difference between:

x:/somepath/  
/x/somepath/ 
x:\somepath\  
....

And is universal path write for all OS? I know the windows use

x:/somepath/

Andrej

Posted 2018-01-06T07:36:04.820

Reputation: 11

Well, you're kind of mixing syntax between OSs. It's better to learn the syntax for each OS, and the syntax for a URI for a file, that's another one. Then you can see ok so windows might also allow forward slashes. Cygwin uses a linux style syntax. so – barlop – 2018-01-06T07:38:27.130

1the c:\ one is windows.. the /c/blah is something you might see in cygwin it follows linux syntax. And the c:/ is just that windows allows forward slashes too but IMO if in windows better to use proper syntax of backslash. There isn't really a universal. – barlop – 2018-01-06T07:40:43.760

Thanks for answer, for example i use shell scripts on windows and executing it from MINGW console , whom is better syntax to write path in this situacion ? – Andrej – 2018-01-06T07:45:48.987

Crossposting: https://stackoverflow.com/q/48125088/3776858

– Cyrus – 2018-01-06T10:44:05.263

@Andrej I just started a mingw console and it says C:\Windows\system32> so what do you think? obviously if the prompt says c:\......> then you use that syntax with the 'drive letter' the colon and the backslashes. If it says dollar like cygwin then you use the linux style syntax with the paths that .cygwin makes for you. Try typing cd it shows you the path that's the syntax you use for paths! – barlop – 2018-01-06T16:35:03.567

Answers

0

Please look at below one by one, I have included images too.

First you will find command execution related to Git Bash then CMD.

enter image description here

C:/Users/SJV/Desktop : works on Git Bash(windows)

SJV@DESKTOP-UNO8EI3 MINGW64 ~
$ clear
(base)
SJV@DESKTOP-UNO8EI3 MINGW64 ~
$ cd C:/Users/SJV/Desktop
(base)
SJV@DESKTOP-UNO8EI3 MINGW64 ~/Desktop
$

/c/Users/SJV/Desktop/ : works same on Git Bash(windows)

(base)
SJV@DESKTOP-UNO8EI3 MINGW64 ~
$ cd /c/Users/SJV/Desktop/
(base)
SJV@DESKTOP-UNO8EI3 MINGW64 ~/Desktop
$

c:\Users\SJV\Desktop : also works same on Git Bash(windows)

(base)
SJV@DESKTOP-UNO8EI3 MINGW64 ~/Desktop
$ cd c:\\Users\\SJV\\Desktop
(base)
SJV@DESKTOP-UNO8EI3 MINGW64 ~/Desktop
$ cd ~
(base)

c:\Users\SJV\Desktop : does not work on Git Bash(windows)

SJV@DESKTOP-UNO8EI3 MINGW64 ~
$ cd c:\Users\SJV\Desktop
bash: cd: c:UsersSJVDesktop: No such file or directory
(base)
SJV@DESKTOP-UNO8EI3 MINGW64 ~
$ 

enter image description here

C:\Users\SJV\Desktop : works on CMD(windows)

C:\Users>cd SJV

C:\Users\SJV>cd C:\Users\SJV\Desktop

C:\Users\SJV\Desktop>
C:\Users\SJV\Desktop>cd /c/Users/SJV
The system cannot find the path specified.

C:\Users\SJV\Desktop>

hygull

Posted 2018-01-06T07:36:04.820

Reputation: 101