Symlinking to a directory gives to different results with
ls -l depending on whether I
ln -s dir or
ln -s dir/. But what's the actual difference, and which one should I prefer why?
The final slash might have ended up there because of shell completion: with some configuration,
The only thing I can think of is that it "protects" you from someone deleting the directory and creating a file.
The version with the slash breaks when the target is replaced with a file.
Interesing question. I've made small test:
As you can see, there is no difference in number of system calls (at least for ls) and traces looks very similar. Howewer, this is just dump test and I'm not sure - there might be some differences.
Your question is really about the behavior of the
1) If you do
2) If you do
3) If you do
4) If you do
Without trailing slash if you may be concerned whether a give directory name is an actual directory versus a symlink to a directory.
With trailing slash if you are more concerned about the files in the directory instead of the directory itself.