📅 2016-Oct-10 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ slash, symbolic link ⬩ 📚 Archive
I recently noticed something strange when creating a symbolic link to a directory:
$ ln -s foo_dir/ slink_to_dir
$ ls -l
drwxrwxr-x 2 ashwin ashwin 4.0K 2016-10-05 21:37 foo_dir/
lrwxrwxrwx 1 ashwin ashwin 7 2016-10-10 21:47 slink_to_dir -> foo_dir//
Notice the double slash (one extra slash) in the destination of the symbolic link.
In fact, you can add multiple slashes and they all show up with one extra slash:
$ ln -s foo_dir/// slink_to_dir
$ ls -l
drwxrwxr-x 2 ashwin ashwin 4.0K 2016-10-05 21:37 foo_dir/
lrwxrwxrwx 1 ashwin ashwin 7 2016-10-10 21:47 slink_to_dir -> foo_dir////
Turns out that this is the standard working of the ln
command. If you are pedantic, you can keep it clean by never specifying a slash when creating a symbolic link using ln:
$ ln -s foo_dir slink_to_dir
Anyway, even if you use the extra slashes they have no effect either since Unix (and Linux) allow and ignore the multiple slashes in a path.
Tried with: Ubuntu 16.04