Skip to main content
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

  • dirname does not check whether the path exists.
  • If path has no directory component (e.g., just a filename), dirname returns ".".
  • To get just the filename, use basename.