Directory of script
It's often useful to know the path of the script being executed, e.g. for sourcing other files.
This solution works as long as the last component of the path used to find the script is not a symlink.
Source: stackoverflow
Last updated