dirname
Quick Reference
Command Name:
dirname
Category:
file management
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
Path manipulation
Extract the directory portion from a file path
- 2
Shell scripting
Build robust scripts that work with file paths
- 3
Directory navigation
Change to parent directories of specific files
- 4
File operations
Perform operations on directories containing specific files
Syntax
dirname [OPTION] NAME...
Options
Option | Description |
---|---|
-z, --zero |
Output null-terminated lines instead of newlines |
--help |
Display help information and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the dirname
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.