How do manipulate file path and names

In emacs elisp, there is a handy function called file-name-nondirectory which accepts a path and file name and returns just a file name and extension. There is also a function called file-name-directory which just returns the dire ctory name without the file.

How can I implement these same functions in perl and bash?

Thanks,
siegfried

Basename for one and dirname for the other - if I have understood you correctly

Or without external commands with bash:

bash 3.2.25(1)$ fn="/usr/local/bin/bash"
bash 3.2.25(1)$ echo "${fn##*/}"
bash
bash 3.2.25(1)$ echo "${fn%/*}"
/usr/local/bin