BASENAME(1) BSD Reference Manual BASENAME(1) NNAAMMEE bbaasseennaammee, ddiirrnnaammee - return filename or directory portion of pathname SSYYNNOOPPSSIISS bbaasseennaammee _s_t_r_i_n_g [_s_u_f_f_i_x] ddiirrnnaammee _s_t_r_i_n_g DDEESSCCRRIIPPTTIIOONN BBaasseennaammee deletes any prefix ending with the last slash `/' character pre- sent in _s_t_r_i_n_g, and a _s_u_f_f_i_x, if given. The resulting filename is writ- ten to the standard output. If _s_t_r_i_n_g ends in the slash character, `/', or is the same as the _s_u_f_f_i_x argument, a newline is output. A non- existant suffix is ignored. DDiirrnnaammee deletes the filename portion, beginning with the last slash `/' character to the end of _s_t_r_i_n_g, and writes the result to the standard output. EEXXAAMMPPLLEESS The following line sets the shell variable FOO to _/_u_s_r_/_b_i_n. FOO=`dirname /usr/bin/trail` Both the bbaasseennaammee and ddiirrnnaammee exit 0 on success, and >0 if an error oc- curs. SSEEEE AALLSSOO csh(1) sh(1) SSTTAANNDDAARRDDSS The bbaasseennaammee and ddiirrnnaammee functions are expected to be POSIX 1003.2 com- patible. 4.4BSD June 6, 1993 1