{"id":3030,"date":"2023-12-22T02:42:00","date_gmt":"2023-12-22T07:42:00","guid":{"rendered":"https:\/\/www.both.org\/?p=3030"},"modified":"2024-06-03T15:09:20","modified_gmt":"2024-06-03T19:09:20","slug":"programming-bash-1-introducing-a-new-series","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=3030","title":{"rendered":"Programming Bash #1 &#8211; Introducing a New Series"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"3030\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>I use Bash all the time, in part because it is the default shell for most Linux distributions, including Fedora and CentOS, the ones I normally use. However I also use Bash because it is an excellent shell and it has a large number of features to make life easier for the Lazy SysAdmin.<\/p>\n\n\n\n<p>Features like tab completion, command line recall and editing, shortcuts like aliases, and more all contribute to its value as a powerful shell. One of my favorite Bash features is that, although it uses Emacs mode for command line editing by default, that can be changed to Vi mode so that I can use editing commands that are already part of my muscle memory.<\/p>\n\n\n\n<p>But if we think of Bash solely as a shell we miss much of its true power. While researching Bash for my three-volume Linux self-study course<sup data-fn=\"d63405f3-4831-4b5b-9610-46fb10723327\" class=\"fn\"><a href=\"#d63405f3-4831-4b5b-9610-46fb10723327\" id=\"d63405f3-4831-4b5b-9610-46fb10723327-link\">1<\/a><\/sup>, upon which this series of articles is based, I learned things about Bash that I never knew in over 20 years of working with Linux. Some of these new bits of knowledge relate to its use as a programming language. Bash is a powerful programming language, one perfectly designed for use on the command line and in shell scripts. For this series we are exploring its use on the command line interface (CLI).<\/p>\n\n\n\n<p>Let\u2019s start with a few basics.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a shell?<\/h2>\n\n\n\n<p>A shell is the command interpreter for for the operating system. Each of the many shells available for Linux interprets the commands typed by the user or SysAdmin into a form usable by the operating system. When the results are returned to the shell program, it displays them on the terminal. All of the shells with which I am familiar are also programming languages.<\/p>\n\n\n\n<p>Bash stands for Bourne Again Shell because the Bash shell is based upon the older Bourne shell which was written by Steven Bourne in 1977. Many other shells are available.<sup><a href=\"http:\/\/www.linux-databook.info\/?page_id=6437#3bfd62eb-9ed3-4b14-82c3-e4e3c40ad4c9\">2<\/a><\/sup> The four I list here are the ones I encounter most frequently but many others exist.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>csh \u2013 the C shell for programmers who like the syntax of the C language.<\/li>\n\n\n\n<li>ksh \u2013 the Korn shell, written by David Korn and popular with Unix users.<\/li>\n\n\n\n<li>tcsh \u2013 a version of csh with more ease of use features.<\/li>\n\n\n\n<li>zsh \u2013 which combines many features of other popular shells.<\/li>\n<\/ul>\n\n\n\n<p>All shells have some built-in commands that supplement or replace the commands provided by the core utilities. Open the man page for Bash and find the \u201cBUILT-INS\u201d section to see the list of commands provided by the shell itself.<\/p>\n\n\n\n<p>I have used the C shell, the Korn shell and the Z shell. I still like the Bash shell more than any of the others I have tried. Each shell has its own personality and syntax. Some will work better for you and others not so well. Use the one that works best for you, but that might require that you at least try some of the others. You can change shells quite easily.<\/p>\n\n\n\n<p>All of these shells are programming languages as well as a command interpreter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">About this Series<\/h2>\n\n\n\n<p>There are seven additional articles in this series. Each of the first four articles introduces you to an aspect of Bash such as its use on the command line, using loops and logical operations. The final four articles will introduce you to programming with Bash, both from the command line as well as the use of Bash programs which are also known as scripts.<\/p>\n\n\n\n<hr class=\"wp-block-separator alignfull has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Series Articles<\/h2>\n\n\n\n<p>This list contains links to all eight articles in this series about Bash.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.both.org\/?p=3030\" target=\"_blank\" rel=\"noreferrer noopener\">Programming Bash #1 \u2013 Introducing a New Series<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.both.org\/?p=3033\" target=\"_blank\" rel=\"noreferrer noopener\">Programming Bash #2: Getting Started<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.both.org\/?p=3038\" target=\"_blank\" rel=\"noreferrer noopener\">Programming Bash #3: Logical Operators<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.both.org\/?p=3041\" target=\"_blank\" rel=\"noreferrer noopener\">Programming Bash #4: Using Loops<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.both.org\/?p=3043\" target=\"_blank\" rel=\"noreferrer noopener\">Programming Bash #5: Automation with Scripts<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.both.org\/?p=3047\" target=\"_blank\" rel=\"noreferrer noopener\">Programming Bash #6: Creating a template<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.both.org\/?p=3052\" target=\"_blank\" rel=\"noreferrer noopener\">Programming Bash #7: Bash Program Needs Help<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.both.org\/?p=3055\" target=\"_blank\" rel=\"noreferrer noopener\">Programming Bash #8: Initialization and sanity testing<\/a><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n<ol class=\"wp-block-footnotes\"><li id=\"d63405f3-4831-4b5b-9610-46fb10723327\">Both, David, <a href=\"https:\/\/www.both.org\/?page_id=2208\" data-type=\"post\" data-id=\"2365\" target=\"_blank\" rel=\"noreferrer noopener\">Using and Administering Linux \u2013 Zero to SysAdmin: 2nd Edition<\/a>, Apress, 2023 <a href=\"#d63405f3-4831-4b5b-9610-46fb10723327-link\" aria-label=\"Jump to footnote reference 1\">\u21a9\ufe0e<\/a><\/li><\/ol>","protected":false},"excerpt":{"rendered":"<p>I use Bash all the time, in part because it is the default shell for most Linux distributions,<\/p>\n","protected":false},"author":2,"featured_media":2388,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":"[{\"content\":\"Both, David, <a href=\\\"https:\/\/www.both.org\/?page_id=2208\\\" data-type=\\\"post\\\" data-id=\\\"2365\\\" target=\\\"_blank\\\" rel=\\\"noreferrer noopener\\\">Using and Administering Linux \u2013 Zero to SysAdmin: 2nd Edition<\/a>, Apress, 2023\",\"id\":\"d63405f3-4831-4b5b-9610-46fb10723327\"}]"},"categories":[149,5,150],"tags":[151,152],"class_list":["post-3030","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash","category-linux","category-programming","tag-bash","tag-programming"],"modified_by":"David Both","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/3030","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3030"}],"version-history":[{"count":10,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/3030\/revisions"}],"predecessor-version":[{"id":5663,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/3030\/revisions\/5663"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/2388"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}