← 返回命令列表

Linux command

dirname 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Get

dirname [/path/to/file.txt]

Multiple

dirname -z [file1] [file2]

说明

dirname extracts the directory portion of a pathname, removing the last component. It's commonly used in shell scripts to find the directory containing a file or script. The command is the complement to basename.

参数

-z, --zero
Separate output with NUL instead of newline

FAQ

What is the dirname command used for?

dirname extracts the directory portion of a pathname, removing the last component. It's commonly used in shell scripts to find the directory containing a file or script. The command is the complement to basename.

How do I run a basic dirname example?

Run `dirname [/path/to/file.txt]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -z, --zero do in dirname?

Separate output with NUL instead of newline