{"id":1737,"date":"2022-02-12T19:53:31","date_gmt":"2022-02-12T14:23:31","guid":{"rendered":"https:\/\/smarttech101.com\/?p=1737"},"modified":"2023-03-25T00:53:37","modified_gmt":"2023-03-24T19:23:37","slug":"basename-dirname-directory-name","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/","title":{"rendered":"How to get the basename and directory of a file in Linux"},"content":{"rendered":"\n

Getting the basename of a file (ex – \/usr\/file.mp4’s basename is file.mp4) and the directory, it is in, is very important especially while writing shell scripts. In this article, we will explore how we can do this using basename <\/strong>and dirname<\/strong> commands. At the same time, I will also mention a few basic applications.<\/p>\n\n\n\n

Table of Contents<\/h2>\n\n\n\n