dirname $(readlink -f "$0")
Output
$ /path/to/dir/script.sh /path/to/dir
basename $(readlink -f "$0")
$ /path/to/dir/script.sh script.sh