Linux命令(108)之dirname

简介: Linux命令(108)之dirname

linux命令之dirname

1.dirname介绍
linux命令dirname是用来获取文件的指定路径

2.dirname用法
dirname [参数] NAME

dirname参数
参数 说明
-z 使用NUL而不是换行符分隔输出
--help 查看帮助信息
--version 查看版本信息
3.实例
3.1.获取文件的指定路径
命令:

dirname ztj.txt

OR

dirname /root/ztj.txt

OR

dirname /a/b/c/d

[root@rhel77 ~]# dirname ./ztj.txt
. ---当前目录
[root@rhel77 ~]# dirname /root/ztj.txt
/root
[root@rhel77 ~]# dirname /a/b/c/d
/a/b/c
[root@rhel77 ~]#
3.2.使用NUL而不是换行符分隔输出
命令:

dirname -z /a/b/c/d

[root@rhel77 ~]# dirname -z /a/b/c/d
/a/b/c[root@rhel77 ~]#
3.3.查看版本信息
命令:

dirname --version

[root@rhel77 ~]# dirname --version
dirname (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie and Jim Meyering.
[root@rhel77 ~]#
3.4.查看帮助信息
命令:

dirname --help

[root@rhel77 ~]# dirname --help
Usage: dirname [OPTION] NAME...
Output each NAME with its last non-slash component and trailing slashes
removed; if NAME contains no /'s, output '.' (meaning the current directory).

-z, --zero separate output with NUL rather than newline
--help display this help and exit
--version output version information and exit

Examples:
dirname /usr/bin/ -> "/usr"
dirname dir1/str dir2/str -> "dir1" followed by "dir2"
dirname stdio.h -> "."

GNU coreutils online help: http://www.gnu.org/software/coreutils/
For complete documentation, run: info coreutils 'dirname invocation'
You have new mail in /var/spool/mail/root
[root@rhel77 ~]#
————————————————
版权声明:本文为CSDN博主「小黑要上天」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/z19861216/article/details/134069775

目录
相关文章
|
3天前
|
SQL 缓存 监控
|
3天前
|
前端开发 Linux Shell
|
2天前
|
Linux
Linux系统ps命令
这些是一些常见的 `ps`命令选项和用法,用于查看系统中运行的进程及其相关信息。您可以根据需要选择合适的选项以满足您的任务要求。
10 0
|
2天前
|
存储 Linux Shell
linux课程第二课------命令的简单的介绍2
linux课程第二课------命令的简单的介绍2
|
2天前
|
Linux C语言 数据安全/隐私保护
linux课程第二课------命令的简单的介绍3
linux课程第二课------命令的简单的介绍3
|
3天前
|
监控 Unix Linux
如何使用 Linux less 命令?
【4月更文挑战第25天】
13 1
如何使用 Linux less 命令?
|
3天前
|
JSON 网络协议 Linux
Linux ip命令:网络的瑞士军刀
【4月更文挑战第25天】
9 1
|
3天前
|
安全 Linux C语言
linux课程第一课------命令的简单的介绍
linux课程第一课------命令的简单的介绍
|
3天前
|
网络协议 Linux Shell
|
3天前
|
NoSQL Linux Shell
2.Docker常用命令(linux)
2.Docker常用命令(linux)