${0} is the first argument of the script, i.e. the script name or path. If you launch your script as path/to/script.sh, then ${0} will be exactly that string: path/to/script.sh.
The %/* part modifies the value of ${0}. It means: take all characters until / followed by a file name. In the example above, ${0%/*} will be path/to.
You can see it in action on your shell:
$ x=path/to/script.sh
$ echo "${x%/*}"
path/to
Sh supports many other kinds of "parameter substitution". Here is, for example, how to take the file name instead of the path:
$ echo "${x##*/}"
script.sh
In general, % and %% strip suffixes, while # and ## strip prefixes. You can read more about parameter substitution.
dirnamecommand like$(dirname $0)– alwayslearning Jan 07 '18 at 05:45dirnameis built in? It certainly isn't in Bash v4.3.11 which is the default shell in Ubuntu Trusty. – David Foerster Jan 07 '18 at 21:15dirnameis not a shell built-in. – alwayslearning Jan 08 '18 at 02:03