[dirname] Get the directory portion of a path

Created on November 30, 2026

Use dirname to print the path after removing its final component.

dirname /var/log/nginx/access.log
/var/log/nginx

Use basename if you need only the final filename component.

Reference

Shell command