linux bash路径
How to get the directory path and file name from a absolute path in Bash on Linux? For example, with “/foo/bar/baz.txt”, it will produce: “/foo/bar/” and “baz.txt”.
如何在Linux上的 Bash中从绝对路径获取目录路径和文件名? 例如,使用“ /foo/bar/baz.txt”,它将产生:“ / foo / bar /”和“ baz.txt”。
You also have the basename and dirname commands besides of the basename and dirname C API in Linux:
除了Linux中的 C API的basename和dirname外,您还具有basename和dirname命令:
[zma@laptop:~]$ p="/foo/bar/baz.txt"
[zma@laptop:~]$ dirname $p
/foo/bar
[zma@laptop:~]$ basename $p
baz.txt
Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。
linux bash路径