Symbolic link and hard link questions

hard linksymlink

Let's say /A/B/c.sh is symbolic linked to /X/Y/c.sh.

  • If c.sh has the command "./SOMETHING", '.' means /A/B/ or /X/Y/?
  • How about the hard link?

Best Answer

. is actually the current working directory in either case; it has nothing to do with the directory holding the script:

[/tmp] $ echo "realpath ." > test.sh && chmod +x test.sh
[/tmp] $ /tmp/test.sh
/tmp
[/tmp] $ cd /usr/bin
[/usr/bin] $ /tmp/test.sh
/usr/bin
Related Question