Bash get basename of filename or directory name


#1

Originally published at: https://www.cyberciti.biz/faq/bash-get-basename-of-filename-or-directory-name/

I need to extract file basename in bash running on Linux. How can I use bash to get basename of filename or directory name for given path?


#2

basename xx/yy/zz = zz
dirname xxx/yy/zz = xxx/yy