I accidently types cd // and was surprised to see OS X take me to a directory called //. It appears to be the root directory, but I am wondering why the cd // command did not throw an error.
Does // have any special meaning?
Seans-MacBook-Pro:/ sean$ cd //
Seans-MacBook-Pro:// sean$ pwd
//
Seans-MacBook-Pro:// sean$ ls
Applications archive net
Incompatible Software bin opt
Library cores private
Network dev sbin
System etc tmp
User Guides And Information home usr
Users mach_kernel var
Volumes mds
Seans-MacBook-Pro:// sean$ cd /
Seans-MacBook-Pro:/ sean$ ls
Applications archive net
Incompatible Software bin opt
Library cores private
Network dev sbin
System etc tmp
User Guides And Information home usr
Users mach_kernel var
Volumes mds
EDIT
I also noticed that cd ///, cd //// etc all resolve to root, and do not give an error. Only cd // is registered as being in the // directory.
Seans-MacBook-Pro:~ sean$ cd ///
Seans-MacBook-Pro:/ sean$ cd //
Seans-MacBook-Pro:// sean$
The
/character is used as a separator, and – generally – any number of them can be collapsed into a single one. (This happens at the shell level, so whenbashis parsing your input, for example)This is also another way to write
/Users/Sean/–////Users////Sean//. However, the “//” is slightly special in some cases. You’re still at the root (/) butbashdoes not collapse it immediately.For more information, see this SuperUser post:
https://superuser.com/questions/389338/which-directory-does-path-represent-in-linux