How to return the directory portion of a pathname Commands Add comments Jan 022010 How to return the directory portion of a pathname Answer: Use the "dirname" command, e.g. # dirname /usr/sbin/ufw /usr/sbin Related posts: Return the last evaluated statement from function in Perl List the size of sub directories in the current directory How to change the MySQL temporary directory Rename directory in Linux How to count the number of files in a directory? Leave a Reply Cancel reply Name (required) E-mail (required) URI Your Comment You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>