dirname - return directory portion of pathname
dirname string [...]
dirname [-z] string [...]
The dirname utility deletes the filename portion, beginning with the last slash '/' character to the end of string (after first stripping trailing slashes), and writes the result to the standard output.
Options | Use |
---|---|
-z|--zero | End each output line with NUL, not newline |
--debug | Enable debug mode |
--help|-? | Print usage and a short help message and exit |
--version | Print version and exit |
-- | Options processing terminator |
Contrary to the original FreeBSD dirname command, this version takes the POSIXLY_CORRECT environment variable into account, disabling all the command's options except the options terminator (--).
The dirname utility exits 0 on success, and >0 if an error occurs.
basename(1) csh(1), sh(1), dirname(3)
The dirname utility is expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.
This version is fully compatible with the FreeBSD version (apart from the help and error messages). It also implements the GNU coreutils version specific options ( -z --zero ).
It tries to follow the PEP 8 style guide for Python code.
Tested OK under Windows (though with backslashes instead os slashes, of course).
The dirname utility first appeared in 4.4BSD.
This version was made for the PNU project in order to test the b2bt command.
This utility is available under the 3-clause BSD license.
This version was written by Hubert Tournier.
The man page is derived from the FreeBSD project's one.