Skip to main content
basename(path) returns the final component of path, stripping any directory prefix.

Signature

Example

Extract the filename from a variable holding a full artifact path and use it as the upload target name:
/workspace/dist/myapp-1.2.0-linux-amd64.tar.gz becomes myapp-1.2.0-linux-amd64.tar.gz.

Notes

  • basename does not check whether the path exists.
  • Trailing slashes in path are stripped before extracting the base name.
  • To get the directory component, use dirname.