Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Isn't A the same as A/ ?

Why they are treated differently by ln ?

share|improve this question

migrated from serverfault.com Dec 21 '10 at 4:39

This question came from our site for professional system and network administrators.

add comment

1 Answer

EDIT: I misread the question - I thought you were asking about ls, but you were asking about ln - thanks Martijn for the comment.

Anyway, I don't see any difference on my side:

$ mkdir 1
$ touch 2
$ ls -l
total 4
drwxr-xr-x 2 user user 4096 2010-12-20 21:48 1
-rw-r--r-- 1 user user    0 2010-12-20 21:48 2
$ ln -s 1 3
$ ln -s 1/ 3s
$ ln -s 2 4
$ ln -s 2/ 4s
$ ls -l
total 4
drwxr-xr-x 2 user user 4096 2010-12-20 21:48 1
-rw-r--r-- 1 user user    0 2010-12-20 21:48 2
lrwxrwxrwx 1 user user    1 2010-12-20 21:48 3 -> 1
lrwxrwxrwx 1 user user    2 2010-12-20 21:48 3s -> 1/
lrwxrwxrwx 1 user user    1 2010-12-20 21:48 4 -> 2
lrwxrwxrwx 1 user user    2 2010-12-20 21:48 4s -> 2/

As for ls from my previous edit...

There may be differences e.g. on symlinks:

$ ls -l
total 0
$ mkdir 1
$ echo 1>1/a
$ find
.
./1
./1/a
$ ln -s 1 2
$ ls -l
total 4
drwxr-xr-x 2 user user 4096 2010-12-19 13:17 1
lrwxrwxrwx 1 user user    1 2010-12-19 13:17 2 -> 1
$ ls -l 1
total 4
-rw-r--r-- 1 user user 1 2010-12-19 13:17 a
$ ls -l 2
lrwxrwxrwx 1 user user 1 2010-12-19 13:17 2 -> 1
$ ls -l 2/
total 4
-rw-r--r-- 1 user user 1 2010-12-19 13:17 a

It is better to think of it like this:

  • ls A lists A
  • ls A/ actually lists A/., where . is a special file denoting current directory

Thus, for symlinks ls A list the symlink, while ls A/ == ls A/. list the contents of the folder pointed to by the symlink.

For more details, take a look here:

section 4.12 Pathname Resolution.

share|improve this answer
    
The asker wasn't talking about 'ls' but 'ln -s', the command to create symlinks. –  Martijn Heemels Dec 20 '10 at 21:53
    
@Martijn Thanks a lot - I misread that part... Edited for the future. –  icyrock.com Dec 21 '10 at 2:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.