dirname(path) returns all but the last element of path, effectively returning the parent directory.
Signature
Example
Derive the working directory for a task from a variable that points to a specific binary or config file:services/api/config.yaml becomes services/api.
Notes
dirnamedoes not check whether the path exists.- If
pathhas no directory component (e.g., just a filename),dirnamereturns".". - To get just the filename, use
basename.