LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What is the diff between / and // (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-the-diff-between-and-236924/)

stardotstar 09-29-2004 10:53 PM

What is the diff between / and //
 
I am wondering what the difference between cd / and cd // is.

I am prompted to ask the question after encountering the following shell session:

Code:

[root@stardot forum]# cd //
[root@stardot //]# pwd
//
[root@stardot //]# ls
bin  boot  dev  etc  home  initrd  lib  lost+found  misc  mnt  opt  proc  root  sbin  selinux  sys  tmp  usr  var
[root@stardot //]# cd ////
[root@stardot /]# cd /
[root@stardot /]# ls
bin  boot  dev  etc  home  initrd  lib  lost+found  misc  mnt  opt  proc  root  sbin  selinux  sys  tmp  usr  var
[root@stardot /]# cd //
[root@stardot //]# ls
bin  boot  dev  etc  home  initrd  lib  lost+found  misc  mnt  opt  proc  root  sbin  selinux  sys  tmp  usr  var
[root@stardot //]# pwd
//
[root@stardot //]# cd ..
[root@stardot //]# pwd
//
[root@stardot //]# cd /./
[root@stardot /]# ls -lasd //
4 drwxr-xr-x  21 root root 4096 Sep 30 12:02 //
[root@stardot /]#

I think you will quickly see what I am getting at...

TIA

Will*

CroMagnon 09-30-2004 01:02 AM

There is no difference in those two cd commands, except that due to a small quirk in the shell, it prints the current path as // instead of /
Sometimes a script will end up with two /'s together in the middle of a path due to a / not being stripped off the end of a paramter - it makes no difference.
(example: ./configure --prefix=/usr/ might result in a path /usr//bin being used - this will just be /usr/bin)


All times are GMT -5. The time now is 01:21 AM.