3

I have on occasion accidentally typed this to change to the root directory.

$ cd //

It works fine and I am in the root directory because ls returns same results as if I am on root. But why is this even valid ?

Bon Ami
  • 155
  • 1
    http://unix.stackexchange.com/questions/1910/how-linux-handles-multiple-path-separators-home-username-file, http://superuser.com/questions/389338/which-directory-does-path-represent-in-linux, http://superuser.com/questions/584234/difference-between-and-directories-in-bash-osx – muru Apr 02 '15 at 18:58

1 Answers1

2

You can add as many slashes as you want after each other at any position. It doesn't change anything.

You also can add ./ as often as you want because "." is the link from every directory to itself.

This and other acrobatics even work when you're saving files. I often will save files with names like "/tmp/a.png". The last time was about 4 minutes ago.

Try it with the address bar of your browser on any page. Same thing.

UTF-8
  • 5,710
  • 10
  • 31
  • 67
  • http://askubuntu.com////////questions/604562/why-does-the-path-exists/ gave me a HTTP 404 – Bon Ami Apr 02 '15 at 18:10
  • Ooops. There is this thing where URLs like this are chopped apart and put together to something like http://askubuntu.com/usercontent/questions.php?id=604562. It probably doesn't work with that. Anyway: It works on your terminal. ;-) – UTF-8 Apr 02 '15 at 18:13
  • If this answered your question, please mark it accordingly. – UTF-8 Apr 02 '15 at 18:47