{"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<p>Getting the basename of a file (ex &#8211; \/usr\/file.mp4&#8217;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 <strong>basename <\/strong>and <strong>dirname<\/strong> commands. At the same time, I will also mention a few basic applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#how-to-find-a-basename-of-a-file\">How to find a basename of a file<\/a><\/li>\n\n\n\n<li><a href=\"#how-to-get-basename-of-multiple-files-at-once\">How to get basename of multiple files at once<\/a><\/li>\n\n\n\n<li><a href=\"#how-to-remove-the-extension-of-a-file-in-linux\">How to remove the extension of a file in Linux<\/a><\/li>\n\n\n\n<li><a href=\"#how-to-find-directory-of-a-file-using-dirname-in-linux\">How to find directory of a file using dirname in Linux<\/a><\/li>\n\n\n\n<li><a href=\"#how-to-find-directories-of-multiple-files\">How to find directories of multiple files<\/a><\/li>\n\n\n\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-find-a-basename-of-a-file\">How to find a basename of a file<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ basename \/usr\/bin\/sort<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sort<\/code><\/pre>\n\n\n\n<p><strong>Application:<\/strong> It is highly useful in getting the basename of a script it is used in. I use this to write &#8216;helps&#8217; in my scripts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ cat time.sh\n\n#!\/bin\/bash\n\nhelp_page(){\ncat &lt;&lt; document\n...\nexample:  $(basename \"$0\") -t 30m 10m\n...\ndocument\n}\n\nhelp_page<\/code><\/pre>\n\n\n\n<p>After executing the above script, we get<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\nexample:  time.sh -t 30m 10m\n...<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-get-basename-of-multiple-files-at-once\">How to get basename of multiple files at once<\/h2>\n\n\n\n<p>You can use <code>--multiple<\/code> or <code>-a<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ basename --multiple dir\/file1 dir\/file2<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>file1\nfile2<\/code><\/pre>\n\n\n\n<p>You can notice that each output line (in the above example, <code>file1<\/code> and <code>file2<\/code>) is appended with the newline character (<code>\\n<\/code>). To remove the <code>\\n<\/code>, use <code>--zero<\/code> or <code>-z<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ basename --zero --multiple dir\/file1 dir\/file2<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>file1file2&#91;ajay@lenovo ~]$<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-remove-the-extension-of-a-file-in-linux\">How to remove the extension of a file in Linux<\/h2>\n\n\n\n<p>You need to append the suffix (i.e. the file extension) next to the file name. Consequently, it will remove the extension along with the directory name.<\/p>\n\n\n\n<p>Syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ basename NAME &#91;SUFFIX]<\/code><\/pre>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ basename dir\/file.mp4 .mp4<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>file<\/code><\/pre>\n\n\n\n<p>Alternatively, you can use <code>--suffix=&lt;your_extension&gt;<\/code> as well. Here, -s is the same as <code>--suffix<\/code>. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ basename --suffix=.mp4 dir\/file.mp4<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-find-directory-of-a-file-using-dirname-in-linux\">How to find directory of a file using dirname in Linux<\/h2>\n\n\n\n<p>Syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ dirname &#91;OPTION] NAME...\n<\/code><\/pre>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ dirname '\/home\/ajay\/Documents\/Notes\/Personal Notebooks'\n\n\/home\/ajay\/Documents\/Notes<\/code><\/pre>\n\n\n\n<p>If NAME contains no \/&#8217;s, output is &#8216;.&#8217; meaning the current directory. For example, <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ dirname file.mp4<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.<\/code><\/pre>\n\n\n\n<p><strong>Application: <\/strong>dirname is used very often to move in the directory of the script. For example, in my rclone.sh script, I use the following command for rclone&#8217;s logs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"939\" height=\"309\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/dirname-2.png?resize=939%2C309&#038;ssl=1\" alt=\"\" class=\"wp-image-1747\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/dirname-2.png?w=939&amp;ssl=1 939w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/dirname-2.png?resize=768%2C253&amp;ssl=1 768w\" sizes=\"(max-width: 939px) 100vw, 939px\" \/><figcaption class=\"wp-element-caption\">fig: see the dirname in the rectangle<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-find-directories-of-multiple-files\">How to find directories of multiple files<\/h2>\n\n\n\n<p>Just use the names of all the files separated by space. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ dirname 'dir1\/file1' 'dir2\/file2'<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dir1\ndir2<\/code><\/pre>\n\n\n\n<p>In the above output, as you can see, the lines are separated by the newline character. Just like basename, to remove the newline character, use <code>--zero<\/code> flag.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ dirname --zero 'dir1\/file1' 'dir2\/file2'<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dir1dir2&#91;ajay@lenovo ~]$ <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>That&#8217;s all folks about the basename and dirname. These two commands, although super simple, come very handy while <a href=\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\" target=\"_blank\" rel=\"noreferrer noopener\">writing shell scripts<\/a>. If you have any comments, suggestions, problems, or criticism, please mention them below. It will help the community.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will explore how we can find the basename and directory&#8217;s name of a file and where they are used.<\/p>\n","protected":false},"author":2,"featured_media":1748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[17],"tags":[18],"class_list":["post-1737","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line-tools","tag-command-line-tools"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to get the basename and directory of a file in Linux | SmartTech101<\/title>\n<meta name=\"description\" content=\"Here, we will explore how we can find the basename and directory&#039;s name of a file using basename and dirname and where they are used.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to get the basename and directory of a file in Linux | SmartTech101\" \/>\n<meta property=\"og:description\" content=\"Here, we will explore how we can find the basename and directory&#039;s name of a file using basename and dirname and where they are used.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/\" \/>\n<meta property=\"og:site_name\" content=\"SmartTech101\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-12T14:23:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-24T19:23:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ajay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ajay_yadav\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/\"},\"author\":{\"name\":\"Ajay\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\"},\"headline\":\"How to get the basename and directory of a file in Linux\",\"datePublished\":\"2022-02-12T14:23:31+00:00\",\"dateModified\":\"2023-03-24T19:23:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/\"},\"wordCount\":401,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png?fit=1280%2C720&ssl=1\",\"keywords\":[\"Command Line Tools\"],\"articleSection\":[\"Command Line Tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/\",\"url\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/\",\"name\":\"How to get the basename and directory of a file in Linux | SmartTech101\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png?fit=1280%2C720&ssl=1\",\"datePublished\":\"2022-02-12T14:23:31+00:00\",\"dateModified\":\"2023-03-24T19:23:37+00:00\",\"description\":\"Here, we will explore how we can find the basename and directory's name of a file using basename and dirname and where they are used.\",\"breadcrumb\":{\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png?fit=1280%2C720&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png?fit=1280%2C720&ssl=1\",\"width\":1280,\"height\":720,\"caption\":\"basename and dirname to find basename and directory name\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/smarttech101.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to get the basename and directory of a file in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/smarttech101.com\/#website\",\"url\":\"https:\/\/smarttech101.com\/\",\"name\":\"SmartTech101\",\"description\":\"Do Everything in Linux\",\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/smarttech101.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\",\"name\":\"Ajay Yadav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"width\":180,\"height\":60,\"caption\":\"Ajay Yadav\"},\"logo\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\",\"name\":\"Ajay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"caption\":\"Ajay\"},\"sameAs\":[\"https:\/\/x.com\/ajay_yadav\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to get the basename and directory of a file in Linux | SmartTech101","description":"Here, we will explore how we can find the basename and directory's name of a file using basename and dirname and where they are used.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/","og_locale":"en_US","og_type":"article","og_title":"How to get the basename and directory of a file in Linux | SmartTech101","og_description":"Here, we will explore how we can find the basename and directory's name of a file using basename and dirname and where they are used.","og_url":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/","og_site_name":"SmartTech101","article_published_time":"2022-02-12T14:23:31+00:00","article_modified_time":"2023-03-24T19:23:37+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png","type":"image\/png"}],"author":"Ajay","twitter_card":"summary_large_image","twitter_creator":"@ajay_yadav","twitter_misc":{"Written by":"Ajay","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#article","isPartOf":{"@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/"},"author":{"name":"Ajay","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334"},"headline":"How to get the basename and directory of a file in Linux","datePublished":"2022-02-12T14:23:31+00:00","dateModified":"2023-03-24T19:23:37+00:00","mainEntityOfPage":{"@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/"},"wordCount":401,"commentCount":1,"publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"image":{"@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png?fit=1280%2C720&ssl=1","keywords":["Command Line Tools"],"articleSection":["Command Line Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/smarttech101.com\/basename-dirname-directory-name\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/","url":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/","name":"How to get the basename and directory of a file in Linux | SmartTech101","isPartOf":{"@id":"https:\/\/smarttech101.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#primaryimage"},"image":{"@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png?fit=1280%2C720&ssl=1","datePublished":"2022-02-12T14:23:31+00:00","dateModified":"2023-03-24T19:23:37+00:00","description":"Here, we will explore how we can find the basename and directory's name of a file using basename and dirname and where they are used.","breadcrumb":{"@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smarttech101.com\/basename-dirname-directory-name\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#primaryimage","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png?fit=1280%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png?fit=1280%2C720&ssl=1","width":1280,"height":720,"caption":"basename and dirname to find basename and directory name"},{"@type":"BreadcrumbList","@id":"https:\/\/smarttech101.com\/basename-dirname-directory-name\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smarttech101.com\/"},{"@type":"ListItem","position":2,"name":"How to get the basename and directory of a file in Linux"}]},{"@type":"WebSite","@id":"https:\/\/smarttech101.com\/#website","url":"https:\/\/smarttech101.com\/","name":"SmartTech101","description":"Do Everything in Linux","publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smarttech101.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633","name":"Ajay Yadav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","width":180,"height":60,"caption":"Ajay Yadav"},"logo":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334","name":"Ajay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","caption":"Ajay"},"sameAs":["https:\/\/x.com\/ajay_yadav"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/02\/basename_dirname.png?fit=1280%2C720&ssl=1","_links":{"self":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1737"}],"collection":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/comments?post=1737"}],"version-history":[{"count":5,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1737\/revisions"}],"predecessor-version":[{"id":2674,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1737\/revisions\/2674"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media\/1748"}],"wp:attachment":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media?parent=1737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/categories?post=1737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/tags?post=1737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}