0

I have to determine the directory of a script which is symlinked.

/usr/local/src/myscript/myscript.sh
/usr/local/bin/myscript.sh (Symlink to the one above)

A cronjob executes /usr/local/bin/myscript.sh. Inside myscript.sh I am trying to determine where the original location is (which is /usr/local/src/myscript/ in this case). How to do that?

gorootde
  • 226
  • 1
  • 2
  • 9

1 Answers1

1

The solution is

$( cd "$( dirname "`readlink ${BASH_SOURCE[0]}`" )" && pwd )
gorootde
  • 226
  • 1
  • 2
  • 9