dirname flags & options
Basic usage
Strip the last component from a path, returning the directory.
dirname /usr/local/bin/python3
Multiple paths
Pass multiple paths to get each directory.
dirname /etc/nginx/nginx.conf /var/log/syslog
-z, --zero
Separate output with NUL instead of newlines.
dirname -z /path/to/file1 /path/to/file2
Scripting pattern
Common pattern: get the directory of the currently running script.
SCRIPT_DIR=$(dirname "$0")
Nested paths
Returns the parent at each level.
dirname /a/b/c/d
dirname /a