{"id":26,"date":"2017-10-05T18:44:04","date_gmt":"2017-10-05T18:44:04","guid":{"rendered":"http:\/\/pipeawk.com\/?p=26"},"modified":"2017-10-16T12:32:38","modified_gmt":"2017-10-16T12:32:38","slug":"the-shebang","status":"publish","type":"post","link":"https:\/\/pipeawk.com\/index.php\/2017\/10\/05\/the-shebang\/","title":{"rendered":"The Shebang"},"content":{"rendered":"<p>As the first article, I decided to discuss the &#8220;<strong>Shebang<\/strong>&#8220;, also called many different ways: <strong>sha-bang<\/strong>, <strong>hashbang<\/strong>, <strong>pound-bang<\/strong>, or <strong>hash-pling<\/strong>.<\/p>\n<p>In the UNIX world, there are scripts, in Linux for example, you will find a lot of &#8220;<strong>bash<\/strong>&#8221; scripts, when you edit one of these scripts there is a line at the top of the script, which looks something like:<\/p>\n<blockquote><p>#!\/bin\/bash<\/p><\/blockquote>\n<p><!--more--><\/p>\n<p>This line simply tells the shell, to use the interpreter specified in the shebang <strong>#!\/bin\/bash<\/strong>. In this particular case <strong>\/bin\/bash<\/strong>.<\/p>\n<p>So, let&#8217;s say that you have a script called <strong>dosomething.bash<\/strong>, and the shebang is <strong>#!\/bin\/bash<\/strong>. To execute simple do:<\/p>\n<blockquote><p>.\/dosomething.bash<\/p><\/blockquote>\n<p>The shell will execute something similar to:<\/p>\n<blockquote><p>\/bin\/bash dosomething.bash<\/p><\/blockquote>\n<p>Of course any scripted language can have a shebang #!\/usr\/bin\/perl or #!\/usr\/bin\/python. You get the concept now, right?<\/p>\n<p>Now, you ask, what if the shebang is not there and you execute the script? Let&#8217;s say that our script <strong>dosomething.bash<\/strong> does not have a shebang line.. you can still execute the script by forcing the interpreter:<\/p>\n<blockquote><p>\/bin\/bash dosomething.bash<\/p><\/blockquote>\n<p>Should you type <strong>.\/dosomething.bash<\/strong>, the running shell will assume that the same shell is used, so, if you are running a bash session, life is good, but if you are running a ksh session, life could be bad&#8230;<\/p>\n<p>Hope this article explains the shebang, have fun now in the UNIX world&#8230;<\/p>\n<p>Well, that&#8217;s it, the mystical shebang is explained. Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As the first article, I decided to discuss the &#8220;Shebang&#8220;, also called many different ways: sha-bang, hashbang, pound-bang, or hash-pling. In the UNIX world, there are scripts, in Linux for example, you will find a lot of &#8220;bash&#8221; scripts, when you edit one of these scripts there is a line at the top of the &hellip; <a href=\"https:\/\/pipeawk.com\/index.php\/2017\/10\/05\/the-shebang\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The Shebang&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-unix"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":6,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":49,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/posts\/26\/revisions\/49"}],"wp:attachment":[{"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}