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".
You also have the basename and dirname commands besides of the basename and dirname C API in Linux:
[zma@laptop:~]$ dirname $p
[zma@laptop:~]$ basename $p