linux dirname
The dirname command in Linux is used to extract the directory component from a path or file name. It returns the directory name without the file name or any trailing slashes.
Syntax:
dirname [option] file_name
Options:
-zor--zero: Output a zero byte (null character) at the end of each line.-hor--help: Display help information and exit.-Vor--version: Output version information and exit.
Example:
$ dirname /home/user/example.txt
/home/user
$ dirname /usr/local/bin/
/usr/local
$ dirname /usr/local/bin
/usr/local
$ dirname ./documents/report.docx
./documents
``
原文地址: https://www.cveoy.top/t/topic/h79w 著作权归作者所有。请勿转载和采集!