The dirname() function returns the path component of path. dirname() searches the provided string for the rightmost token and returns everything but the rightmost token. Tokens are delimited with the forward slash character (/). dirname ignores all trailing slashes.

For example, given the string /one/two/three, dirname returns everything but the rightmost token. In this example, result contains /one/two/.

Given the string /one/two/three/, dirname ignores the tailing slash and result contains /one/two.

result = dirname (path);
path Required. Character string that contains a path and file name

result contains the contents of path, minus the rightmost token (that is, the file name). If a token is not found, a . is returned.

In the example,

result = dirname ("/var/adm/pblog.txt");

result contains the directory /var/adm/.