{"id":309,"date":"2014-08-10T10:19:17","date_gmt":"2014-08-10T07:19:17","guid":{"rendered":"http:\/\/www.nano-micro.gr\/bl\/?p=309"},"modified":"2014-08-10T10:19:17","modified_gmt":"2014-08-10T07:19:17","slug":"introduction-unix-bash-shell-programming-ii","status":"publish","type":"post","link":"https:\/\/nano-micro.gr\/bl\/?p=309","title":{"rendered":"Introduction to UNIX BASH shell programming II."},"content":{"rendered":"<p>This is the second post of the &#8220;Introduction to Unix BASH shell programming&#8221; series. Initially, in order to be easier to follow the discussion, some facts concerning the file system structure will be presented. Subsequently,\u00a0 some directory and other basic commands\u00a0 will be discussed, like cp, mv, rm.<\/p>\n<h2>Some Unix File System issues<\/h2>\n<p>The UNIX file system has records which refer to files and directories. These records are called inodes. According to <a href=\"http:\/\/en.wikipedia.org\/wiki\/Inode\" target=\"_blank\">Wikipedia :<\/a><\/p>\n<blockquote><p>In a <a title=\"Unix filesystem\" href=\"http:\/\/en.wikipedia.org\/wiki\/Unix_filesystem\">Unix-style file system<\/a>, an <b>index node<\/b>, informally referred to as an <b>inode<\/b>, is a <a title=\"Data structure\" href=\"http:\/\/en.wikipedia.org\/wiki\/Data_structure\">data structure<\/a> used to represent a filesystem object, which can be one of various things including a file or a directory. Each inode stores the attributes and disk block location(s) of the filesystem object&#8217;s data. Filesystem object attributes may include manipulation <a title=\"Metadata\" href=\"http:\/\/en.wikipedia.org\/wiki\/Metadata\">metadata<\/a> (e.g. change, access, modify time), as well as owner and <a title=\"File system permissions\" href=\"http:\/\/en.wikipedia.org\/wiki\/File_system_permissions\">permission<\/a> data (e.g. <a title=\"Group identifier\" href=\"http:\/\/en.wikipedia.org\/wiki\/Group_identifier\">group-id<\/a>, <a title=\"User identifier\" href=\"http:\/\/en.wikipedia.org\/wiki\/User_identifier\">user-id<\/a>, <a title=\"File system permissions\" href=\"http:\/\/en.wikipedia.org\/wiki\/File_system_permissions\">permissions<\/a>).<\/p><\/blockquote>\n<p><strong>ln<\/strong> &#8211; create link. Creates a new inode that points to the same data (address in the disk). This link is called a hard link. <em>ln [-s] &lt;file name&gt; &lt;link name&gt;<\/em>. When the option -s is used a soft or symbolic link link is created. The symbolic link does not point directly to the data, but to the original inode (much like the link in MS Windows)<\/p>\n<h2>Directory BASH commands<\/h2>\n<p><strong>mkdir<\/strong> &#8211; create a new directory. <em>mkdir &lt;directory name&gt;<\/em>. The directory name may be sdeclared as an absolute or relative path.<\/p>\n<p><strong>rmdir<\/strong> &#8211; remove directory.\u00a0 Delete a directory. <em>rmdir &lt;directory name&gt;<\/em>. The directory name may be declared as an absolute or relative path, but in ant case it must be empty in order to be removed.<\/p>\n<h2>Basic commands<\/h2>\n<p><strong>cp<\/strong> &#8211; copy file(s) or directory(ies).<em>\u00a0 cp [-i] [-r] [-f] &lt;source file(s)&gt; &lt;target file&gt;<\/em>.\u00a0 Any combination of files or directories may be used as source. The source files are separated by space. The target could be a file or a directory. In the case of multiple sources the target is a directory. The names of files and directories may be declared using the absolute or relative path. The copy action creates a new inode with the same contents. Thus, a change in either the source or destination file does not reflect to the the other, in contrast with the hard or symbolic links. The -f option does not ask for a permission to overwrite the destination file, when it already exists.<\/p>\n<p><strong>mv<\/strong> &#8211; move file(s) or directory(ies). mv<em> [-i] [-r] [-f] &lt;source file(s)&gt; &lt;target file&gt;<\/em>.This command behaves the same as the copy command except that it removes (deletes) the source object. If the source and destination file are located in the same directory, then the result of the command is to rename the source file giving it the name of the destination.<\/p>\n<p><strong>rm<\/strong> &#8211; remove file(s) or directory(ies).\u00a0<em> rm [-i] [-r] [-f] &lt;source file(s)&gt; &lt;target file&gt;<\/em>. The -r option removes recursively the contents of the target directory and all subdirectories and files. Be <strong>very careful<\/strong> with this command. For example, rm -rf \/* might delete all the contents of your disk.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the second post of the &#8220;Introduction to Unix BASH shell programming&#8221; series. Initially, in order to be easier to follow the discussion, some facts concerning the file system structure will be presented. Subsequently,\u00a0 some directory and other basic &hellip; <a href=\"https:\/\/nano-micro.gr\/bl\/?p=309\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[24,26,25],"class_list":["post-309","post","type-post","status-publish","format-standard","hentry","category-programming","tag-bash-shell","tag-linux","tag-unix"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Introduction to Unix BASH SHELL programming II<\/title>\n<meta name=\"description\" content=\"Unix BASH shell programming. An introduction to UNIX\/Linux BASH SHELL and BASH SHELL programming, short history along with a brief description of the shell\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nano-micro.gr\/bl\/?p=309\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introduction to Unix BASH SHELL programming II\" \/>\n<meta property=\"og:description\" content=\"Unix BASH shell programming. An introduction to UNIX\/Linux BASH SHELL and BASH SHELL programming, short history along with a brief description of the shell\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nano-micro.gr\/bl\/?p=309\" \/>\n<meta property=\"og:site_name\" content=\"Micro - Nano (Mems, VLSI, Tactile Displays research)\" \/>\n<meta property=\"article:published_time\" content=\"2014-08-10T07:19:17+00:00\" \/>\n<meta name=\"author\" content=\"Vasileios Chouvardas\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vasileios Chouvardas\" \/>\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:\\\/\\\/nano-micro.gr\\\/bl\\\/?p=309#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/?p=309\"},\"author\":{\"name\":\"Vasileios Chouvardas\",\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/#\\\/schema\\\/person\\\/561473c69291dac4c3a692f7ecbce7e8\"},\"headline\":\"Introduction to UNIX BASH shell programming II.\",\"datePublished\":\"2014-08-10T07:19:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/?p=309\"},\"wordCount\":545,\"keywords\":[\"Bash shell\",\"Linux\",\"Unix\"],\"articleSection\":[\"Programming\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/?p=309\",\"url\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/?p=309\",\"name\":\"Introduction to Unix BASH SHELL programming II\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/#website\"},\"datePublished\":\"2014-08-10T07:19:17+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/#\\\/schema\\\/person\\\/561473c69291dac4c3a692f7ecbce7e8\"},\"description\":\"Unix BASH shell programming. An introduction to UNIX\\\/Linux BASH SHELL and BASH SHELL programming, short history along with a brief description of the shell\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/?p=309#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/?p=309\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/?p=309#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nano-micro.gr\\\/bl\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Introduction to UNIX BASH shell programming II.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/#website\",\"url\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/\",\"name\":\"Micro - Nano (Mems, VLSI, Tactile Displays research)\",\"description\":\"Vasileios Chouvardas website\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/#\\\/schema\\\/person\\\/561473c69291dac4c3a692f7ecbce7e8\",\"name\":\"Vasileios Chouvardas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/94cb42ae291156f2206c36eb74fc5ccf05d10ae852f61d6683c0bd213d6f16e4?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/94cb42ae291156f2206c36eb74fc5ccf05d10ae852f61d6683c0bd213d6f16e4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/94cb42ae291156f2206c36eb74fc5ccf05d10ae852f61d6683c0bd213d6f16e4?s=96&d=mm&r=g\",\"caption\":\"Vasileios Chouvardas\"},\"url\":\"https:\\\/\\\/nano-micro.gr\\\/bl\\\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Introduction to Unix BASH SHELL programming II","description":"Unix BASH shell programming. An introduction to UNIX\/Linux BASH SHELL and BASH SHELL programming, short history along with a brief description of the shell","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:\/\/nano-micro.gr\/bl\/?p=309","og_locale":"en_US","og_type":"article","og_title":"Introduction to Unix BASH SHELL programming II","og_description":"Unix BASH shell programming. An introduction to UNIX\/Linux BASH SHELL and BASH SHELL programming, short history along with a brief description of the shell","og_url":"https:\/\/nano-micro.gr\/bl\/?p=309","og_site_name":"Micro - Nano (Mems, VLSI, Tactile Displays research)","article_published_time":"2014-08-10T07:19:17+00:00","author":"Vasileios Chouvardas","twitter_misc":{"Written by":"Vasileios Chouvardas","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nano-micro.gr\/bl\/?p=309#article","isPartOf":{"@id":"https:\/\/nano-micro.gr\/bl\/?p=309"},"author":{"name":"Vasileios Chouvardas","@id":"https:\/\/nano-micro.gr\/bl\/#\/schema\/person\/561473c69291dac4c3a692f7ecbce7e8"},"headline":"Introduction to UNIX BASH shell programming II.","datePublished":"2014-08-10T07:19:17+00:00","mainEntityOfPage":{"@id":"https:\/\/nano-micro.gr\/bl\/?p=309"},"wordCount":545,"keywords":["Bash shell","Linux","Unix"],"articleSection":["Programming"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/nano-micro.gr\/bl\/?p=309","url":"https:\/\/nano-micro.gr\/bl\/?p=309","name":"Introduction to Unix BASH SHELL programming II","isPartOf":{"@id":"https:\/\/nano-micro.gr\/bl\/#website"},"datePublished":"2014-08-10T07:19:17+00:00","author":{"@id":"https:\/\/nano-micro.gr\/bl\/#\/schema\/person\/561473c69291dac4c3a692f7ecbce7e8"},"description":"Unix BASH shell programming. An introduction to UNIX\/Linux BASH SHELL and BASH SHELL programming, short history along with a brief description of the shell","breadcrumb":{"@id":"https:\/\/nano-micro.gr\/bl\/?p=309#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nano-micro.gr\/bl\/?p=309"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nano-micro.gr\/bl\/?p=309#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nano-micro.gr\/bl"},{"@type":"ListItem","position":2,"name":"Introduction to UNIX BASH shell programming II."}]},{"@type":"WebSite","@id":"https:\/\/nano-micro.gr\/bl\/#website","url":"https:\/\/nano-micro.gr\/bl\/","name":"Micro - Nano (Mems, VLSI, Tactile Displays research)","description":"Vasileios Chouvardas website","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nano-micro.gr\/bl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/nano-micro.gr\/bl\/#\/schema\/person\/561473c69291dac4c3a692f7ecbce7e8","name":"Vasileios Chouvardas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/94cb42ae291156f2206c36eb74fc5ccf05d10ae852f61d6683c0bd213d6f16e4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/94cb42ae291156f2206c36eb74fc5ccf05d10ae852f61d6683c0bd213d6f16e4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/94cb42ae291156f2206c36eb74fc5ccf05d10ae852f61d6683c0bd213d6f16e4?s=96&d=mm&r=g","caption":"Vasileios Chouvardas"},"url":"https:\/\/nano-micro.gr\/bl\/?author=2"}]}},"_links":{"self":[{"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=\/wp\/v2\/posts\/309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=309"}],"version-history":[{"count":11,"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=\/wp\/v2\/posts\/309\/revisions"}],"predecessor-version":[{"id":321,"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=\/wp\/v2\/posts\/309\/revisions\/321"}],"wp:attachment":[{"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nano-micro.gr\/bl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}