The Right Way to Get the Directory of a bash Script

When writing bash scripts, you might want to get the directory that contains your script. There are multiple ways to accomplish that. Due to the flexibility of bash, some solutions work in some cases, but not in others…. Source: http://www.ostricher.com/2014/10/the-right-way-to-get-the-directory-of-a-bash-script/