{"id":913,"date":"2014-12-27T00:00:28","date_gmt":"2014-12-26T15:00:28","guid":{"rendered":"http:\/\/www.catracing.org\/hendrb\/?p=913"},"modified":"2016-07-29T01:45:43","modified_gmt":"2016-07-28T16:45:43","slug":"bash-script-guess-number","status":"publish","type":"post","link":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/","title":{"rendered":"BASH Script &#8211; Guess My Number"},"content":{"rendered":"<p><a href=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-917 size-medium\" src=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg\" alt=\"v64_users_guide\" width=\"181\" height=\"300\" srcset=\"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg 181w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide.jpg 278w\" sizes=\"auto, (max-width: 181px) 100vw, 181px\" \/><\/a>Some of the most fun I had with the Commodore Vic-20 and Commodore 64, was entering programs from their user\u2019s manual or magazines and learning how to program in BASIC.\u00a0 Something that I think today\u2019s generation starting to use computers these day are missing out on.\u00a0 The computer has become just another house hold appliance.\u00a0 Where you use a microwave to cook your food.\u00a0 You use a word processor to do your homework, a photo managing software, or video editing software to upload to YouTube to show everyone how cool you are.\u00a0\u00a0 If you know how to navigate around the Macintosh finder, or Windows desktop you\u2019re a computer expert.\u00a0\u00a0 However if you were tasked with writing a very simple program (besides \u2018hello world\u2019, would you be able to do it?<\/p>\n<p>For those of us that use some flavor of the *NIX operating systems, such as Mac OSX, or any of the Linux distributions, we are lucky, because we have a plethora of programing \u201cscripting\u201d languages at our finger tips!<\/p>\n<p>I wanted to demonstrate this capability, by taking one of the very first programs I ever wrote on the Commodore 64.\u00a0 The program lets you pick the difficulty by letting you define the highest number it will \u201cguess\u201d, then randomly generates a number from 1 to that number.\u00a0 You must then guess the number the computer chose and try to do it in the least amount of guesses.\u00a0 It was a very straight forward program, though I did run into a few issues when converting it to a bash script.<\/p>\n<p>The first problem is that I do not have allot of experience programming without line numbers.\u00a0 Even when I converted a couple of programs from my BBS, I was able to simulate line numbers in AREXX by making each line in the script a number such as L1: L2:.\u00a0 Arexx will execute from top to bottom, unless you execute a GOTO, or GOSUB statement.\u00a0 In BASH unless you make a nesting infinite loop, it will execute top to bottom no matter what!\u00a0 There is no equivalent to the GOTO statement.\u00a0 You can define a function and perform the equivalent of a GOSUB, but when the subroutine finishes.\u00a0 It returns to execute exactly where you left off.\u00a0 To me this is quite a limitation, and in my opinion causes bloat.<\/p>\n<p>Here is the listing of the original Commodore 64 program, as it appeared in the User\u2019s Guide.<\/p>\n<p><a href=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/Number-Guess.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-916\" src=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/Number-Guess-1024x714.jpg\" alt=\"Number Guess\" width=\"940\" height=\"655\" srcset=\"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/Number-Guess-1024x714.jpg 1024w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/Number-Guess-300x209.jpg 300w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/Number-Guess-430x300.jpg 430w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/Number-Guess.jpg 1335w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/c-64-In-Action.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-914\" src=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/c-64-In-Action-1024x576.jpg\" alt=\"c-64 In Action\" width=\"940\" height=\"529\" srcset=\"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/c-64-In-Action-1024x576.jpg 1024w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/c-64-In-Action-300x169.jpg 300w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/c-64-In-Action-500x281.jpg 500w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/c-64-In-Action.jpg 1920w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><\/a><\/p>\n<p>I do not have allot of experience with BASH scripting, so there was quite a bit of Google searching and rethinking the operation of the program.\u00a0 One of the biggest stumbling blocks came from the fact that without a go to statement, I had to use an extra variable and create the until loop.\u00a0 Which added several needless lines to the program. (The line numbers here make it easier to read, and later describe the script.\u00a0 Do NOT enter the line numbers!)<\/p>\n<p><a href=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/numberguess.jpg\" rel=\"attachment wp-att-2139\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-large wp-image-2139\" src=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/numberguess-1024x612.jpg\" alt=\"numberguess\" width=\"940\" height=\"562\" srcset=\"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/numberguess-1024x612.jpg 1024w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/numberguess-300x179.jpg 300w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/numberguess-768x459.jpg 768w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/numberguess-500x300.jpg 500w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/numberguess.jpg 1560w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><\/a><\/p>\n<p><span style=\"color: #ffff00;\">1\u00a0#! \/bin\/bash<br \/>\n2\u00a0# BASH Shell version of the Random Number Guessing Game<br \/>\n3\u00a0# Originally published in the Commodore 64 Users Guide.<br \/>\n4\u00a0# Converted to BASH Shell by Brent P Hendricks<br \/>\n5\u00a0# This script in intended to be used with an article<br \/>\n6\u00a0# published on Brent\u2019s World (An American Expat In Korea)<br \/>\n7\u00a0# Please check out the article @ www.catracing.org\/hendrb\/<br \/>\n8\u00a0# This script is public domain, however the article text is<br \/>\n9\u00a0# Copyright 2014 by Brent P. Hendricks, if you use to use<br \/>\n10\u00a0# the article text in part or in full, please contact<br \/>\n11\u00a0# me on my blog.\u00a0 Linking to my article is permitted!<br \/>\n12<br \/>\n13\u00a0clear #- Clears the screen<br \/>\n14<br \/>\n15\u00a0echo &#8220;Randon Number Guessing Game v1.0&#8221;<br \/>\n16\u00a0echo<br \/>\n17\u00a0echo &#8220;Originally published in the Commodore 64 Users Guide in 1982, page 51&#8221;<br \/>\n18\u00a0echo &#8220;Converted to a BASH Shell script by Brent P Hendricks Dec 2014&#8221;<br \/>\n19\u00a0echo &#8220;This script was published in an article demostrating the differences between Commodore Basic and BASH shell Scripting.&#8221;<br \/>\n20\u00a0echo &#8220;If you have a chance, please read the article at Brent\u2019s World www.catracing.org\/hendrb.&#8221;<br \/>\n21\u00a0echo &#8220;This script has been released in the public domain, however the article text is Copyright 2014 by Brent P. Hendricks.&#8221;<br \/>\n22\u00a0echo &#8220;Copying the article text, either in part of in full may only be done with writen permission from the author.&#8221;<br \/>\n23\u00a0echo &#8220;Feel free to link to the article at http:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/&#8221;<br \/>\n24\u00a0echo<br \/>\n25\u00a0echo<br \/>\n26<br \/>\n27\u00a0\u00a0#defines functions<br \/>\n28\u00a0\u00a0guess ()<br \/>\n29\u00a0 \u00a0\u00a0{<br \/>\n30\u00a0\u00a0\u00a0echo<br \/>\n31\u00a0\u00a0\u00a0if [ $GUESS -lt 2 ]<br \/>\n32\u00a0\u00a0\u00a0\u00a0then<br \/>\n33\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0echo<br \/>\n34\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0echo -n &#8220;Enter your first guess : &#8221;<br \/>\n35\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0read AN<br \/>\n36\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0else<br \/>\n37\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0echo<br \/>\n38\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0echo -n &#8220;Enter another guess : &#8221;<br \/>\n39\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0read AN<br \/>\n40\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0fi<br \/>\n41\u00a0\u00a0\u00a0}<br \/>\n42<br \/>\n43\u00a0#define variables<br \/>\n44\u00a0GUESS=1 #Defines variable try (Used to count the number of attempts)<br \/>\n45\u00a0WIN=0 #Defines variable WIN (This is used to determine if the game is over and can exit.).<br \/>\n46\u00a0echo<br \/>\n47\u00a0echo -n &#8220;Enter Upper Limit for your guess: &#8221;<br \/>\n48\u00a0read LIMIT #&#8217;Reads&#8217; Keyboard input and puts the result in variabel LIMIT<br \/>\n49\u00a0# Generates Random Number From variable LIMIT<br \/>\n50<br \/>\n51\u00a0NUMBER=$((RANDOM % $LIMIT))<br \/>\n52\u00a0echo &#8220;I\u2019ve Got The Number.&#8221;<br \/>\n53\u00a0guess #Calls function quess<br \/>\n54<br \/>\n55\u00a0#This can be used for troubleshooting,\u00a0 If the script does not appear to be running correctly.<br \/>\n56\u00a0# You can uncomment these lines to display the results of each game variable.<br \/>\n57<br \/>\n58\u00a0# echo $NUMBER<br \/>\n59\u00a0# echo $AN<br \/>\n60\u00a0# echo $WIN<br \/>\n61<br \/>\n62\u00a0\u00a0until [ $WIN -eq 1 ]<br \/>\n63\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0do<br \/>\n64\u00a0 \u00a0\u00a0if [ $AN -eq $NUMBER ]<br \/>\n65\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0then<br \/>\n66\u00a0\u00a0\u00a0\u00a0\u00a0WIN=1<br \/>\n67\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi<br \/>\n68<br \/>\n69\u00a0\u00a0\u00a0\u00a0 \u00a0if [ $AN -lt $NUMBER ]<br \/>\n70\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0then<br \/>\n71\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0echo &#8220;Sorry, my number is HIGHER.Try again!&#8221;<br \/>\n72\u00a0\u00a0 \u00a0\u00a0\u00a0((GUESS=$GUESS+1))<br \/>\n73\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 guess<br \/>\n74\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0fi<br \/>\n75<br \/>\n76\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ $AN -gt $NUMBER ]<br \/>\n77\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0then<br \/>\n78\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0echo &#8220;Sorry, my number is LOWER. Try again!&#8221;<br \/>\n79\u00a0\u00a0 \u00a0\u00a0\u00a0((GUESS=$GUESS+1))<br \/>\n80\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0guess<br \/>\n81\u00a0\u00a0\u00a0\u00a0 \u00a0fi<br \/>\n82\u00a0\u00a0\u00a0\u00a0 done<br \/>\n83\u00a0echo<br \/>\n84\u00a0echo\u00a0 &#8220;Great! You Got My Number! It Took You $GUESS Tries.&#8221;<br \/>\n85\u00a0echo<br \/>\n86\u00a0echo -n &#8220;Would you like to try another? &#8221;<br \/>\n87\u00a0read an<br \/>\n88<br \/>\n89\u00a0\u00a0if [ an = y ]<br \/>\n90\u00a0\u00a0\u00a0then<br \/>\n91\u00a0\u00a0\u00a0\u00a0exec $.\\number-guess.sh #Replaces currently running program with new number-<br \/>\n92\u00a0guess progrom, BASH does not support GOTO<br \/>\n93\u00a0\u00a0\u00a0else<br \/>\n94\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0echo<br \/>\n95\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0echo &#8220;Please Check Out Brent\u2019s World @ www.catracing.org\/hendrb&#8221;<br \/>\n96\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0fi<br \/>\n97\u00a0exit<\/span><\/p>\n<p>To write a BASH script, you can use any\u00a0text editor\u00a0that you feel comfortable using, in *NIX,\u00a0 I tend to prefer nano, but vi will work as well.<\/p>\n<p>After entering the script into your favorite editor, you need to make the script executable.\u00a0 to do this type chmod 776 &lt;filename&gt; at the command line.Once the script has execute permissions. type .\\&lt;filename&gt; .\u00a0 The .\\ tells the system to execute the file in the current directory, instead of looking in the SEARCH PATH set in the $PATH environment variable.<\/p>\n<p>The first line of your script must contain the statement #!\/bin\/bash.\u00a0 This tells the system that you are executing a script<\/p>\n<p>Between Lines 2 \u2013 11 are the programs comments, similar to the BASIC REMark statement.\u00a0 Any statement following the # command will be ignored by the bash shell.\u00a0 This is also useful while trouble shooting scripts or .conf files, as instead of removing a line.\u00a0 You can simple \u201cPOUND IT OUT\u201d, and the shell will ignore it.<\/p>\n<p>Line 13 simply clears the screen.<\/p>\n<p>15-24 Is simply a sequence of ECHO statements that display the program banner.\u00a0 Echo displays text or variables to the std(OUT) (Screen).\u00a0 Echo has several options that we used in this script, including its NULL state which simply prints a cr\/lf to std(OUT).\u00a0 As you see here with echo being by itself.\u00a0 Echo with no options will output any text in quotes will automatically add a cr\/lf to the end of its text.\u00a0 Sometimes this is undesirable for formatting reason, or if the echo command is being used to create prompt for input followed by a read &lt;variable&gt; statement.\u00a0 You can suppress the addition of the cr\/lf by adding the \u2013n option.\u00a0 As seen in line 38.<\/p>\n<p>26 \u2013 31 is defining a function called \u2018guess\u2019, since BASH does not support a GOTO feature, creating the subroutine that gets called by the DO UNTIL LOOP was an easy solution.\u00a0 In this subroutine you see our first use of the test function [.<\/p>\n<p>Line 30 could also be written in long hand, like this.<\/p>\n<p>If test -$GUESS \u2013lt 2 ]<br \/>\nThen<br \/>\n&lt;do this&gt;<br \/>\nElse<br \/>\n&lt;do that&gt;<br \/>\nfi<\/p>\n<p>The test function allows us to perform tests to determine if a specific condition exists.\u00a0 In this case if the number of GUESS\u2019s is 1,\u00a0 This could also have been write as if [ $GUESS \u2013eq 1).<\/p>\n<p>-eq = Equal to<br \/>\n-lt = Less Then<br \/>\n-gt = Greater Then<\/p>\n<p>The fi in 40 closes out the loop statement, and the } in line 41 tells the interpreter that this is the end of GUESS function.<\/p>\n<p>Line 43 \u2013 45 simply puts default values in 2 variables, GUESS (Which is a counter of how many attempts you have made to guess the number), and WIN = which is simply a condition variable used later in the program so exit the DO UNTIL loop.\u00a0\u00a0 Variables in *Nix are case sensitive.\u00a0 It is common practice to use capital letters, so they are not confused with commands.\u00a0 As noted here, we have a function defined as guess, as well as a variable named GUESS.<\/p>\n<p>Line 48-53 Prompts the users for the upper limit of the number the computer will generate.\u00a0 The computer will pick a number from 1 \u2013 limit.\u00a0 As noted above, the \u2013n option is used after the echo command to suppress echo from automatically adding a cr\/lf after the prompt.\u00a0 Line 49 reads std(IN), in this case the keyboard for input, and places the input in the variable LIMIT<\/p>\n<p>Line 53 generates a random number from 1 &#8211; $LIMIT and places this number in the variable $NUMBER<\/p>\n<p>Line 56 calls the guess function<\/p>\n<p>Lines 58 \u2013 60 where placed by me, as an example of debugging, I wanted to be able to see between each guess that the variables where doing what they are supposed to do<\/p>\n<p>A note about variables.\u00a0 When placing values into a variable you only specify the variable name, with one exception (more about that in a sec.) whereas when reading a variable you must proceed it by a $.<\/p>\n<p>\\Lens 63 \u2013 83.\u00a0 Is what I consider to be bloat caused by the fact BASH does not have a GOTO feature.\u00a0 So I had to assign another variable WIN, and this 3 part UNTIL-DO loop.\u00a0 I suppose you could make the program one whole nested loop inside an infinite loop, but we can save that attempt for a future article.<\/p>\n<p>Line 92, If the user answers they want to play again.\u00a0 Exec $ exits the script and re-runs it.\u00a0 Another brutal solution driven by the lack of a GOTO command.<\/p>\n<p>I hope you try typing in this BASH script, It certainly brought back allot of memory, mostly of the amount of frustration that writing even a simple program can cause.\u00a0 If you would like me to write more articles for the technical portion of my blog please let me know.\u00a0 Also any comments or suggestions on the programming syntax or format..\u00a0 Please let me know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some of the most fun I had with the Commodore Vic-20 and Commodore 64, was entering programs from their user\u2019s manual or magazines and learning how to program in BASIC.\u00a0 Something that I think today\u2019s generation starting to use computers <span class=\"excerpt-dots\">&hellip;<\/span> <a class=\"more-link\" href=\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/\"><span class=\"more-msg\">Continue reading &rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[],"class_list":["post-913","post","type-post","status-publish","format-standard","hentry","category-technical"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>BASH Script - Guess My Number - Brent&#039;s World<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"BASH Script - Guess My Number - Brent&#039;s World\" \/>\n<meta property=\"og:description\" content=\"Some of the most fun I had with the Commodore Vic-20 and Commodore 64, was entering programs from their user\u2019s manual or magazines and learning how to program in BASIC.\u00a0 Something that I think today\u2019s generation starting to use computers &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/\" \/>\n<meta property=\"og:site_name\" content=\"Brent&#039;s World\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Brents-World-912767498915017\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/Brents-World-912767498915017\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-26T15:00:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-07-28T16:45:43+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg\" \/>\n<meta name=\"author\" content=\"Brent Hendricks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brent Hendricks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/\"},\"author\":{\"name\":\"Brent Hendricks\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442\"},\"headline\":\"BASH Script &#8211; Guess My Number\",\"datePublished\":\"2014-12-26T15:00:28+00:00\",\"dateModified\":\"2016-07-28T16:45:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/\"},\"wordCount\":1766,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442\"},\"image\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg\",\"articleSection\":[\"Technical\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/\",\"url\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/\",\"name\":\"BASH Script - Guess My Number - Brent&#039;s World\",\"isPartOf\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg\",\"datePublished\":\"2014-12-26T15:00:28+00:00\",\"dateModified\":\"2016-07-28T16:45:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#primaryimage\",\"url\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg\",\"contentUrl\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.catracing.org\/hendrb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"BASH Script &#8211; Guess My Number\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/#website\",\"url\":\"https:\/\/www.catracing.org\/hendrb\/\",\"name\":\"Brent&#039;s World\",\"description\":\"Your weekly dose of the life of Brent!\",\"publisher\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.catracing.org\/hendrb\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442\",\"name\":\"Brent Hendricks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2019\/05\/Brent-Sitting-portrait-2.jpg\",\"url\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2019\/05\/Brent-Sitting-portrait-2.jpg\",\"contentUrl\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2019\/05\/Brent-Sitting-portrait-2.jpg\",\"width\":4480,\"height\":6720,\"caption\":\"Brent Hendricks\"},\"logo\":{\"@id\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2019\/05\/Brent-Sitting-portrait-2.jpg\"},\"sameAs\":[\"http:\/\/www.catracing.org\",\"https:\/\/www.facebook.com\/Brents-World-912767498915017\"],\"url\":\"https:\/\/www.catracing.org\/hendrb\/author\/hendrb01\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"BASH Script - Guess My Number - Brent&#039;s World","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:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/","og_locale":"en_US","og_type":"article","og_title":"BASH Script - Guess My Number - Brent&#039;s World","og_description":"Some of the most fun I had with the Commodore Vic-20 and Commodore 64, was entering programs from their user\u2019s manual or magazines and learning how to program in BASIC.\u00a0 Something that I think today\u2019s generation starting to use computers &hellip; Continue reading &rarr;","og_url":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/","og_site_name":"Brent&#039;s World","article_publisher":"https:\/\/www.facebook.com\/Brents-World-912767498915017","article_author":"https:\/\/www.facebook.com\/Brents-World-912767498915017","article_published_time":"2014-12-26T15:00:28+00:00","article_modified_time":"2016-07-28T16:45:43+00:00","og_image":[{"url":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg","type":"","width":"","height":""}],"author":"Brent Hendricks","twitter_misc":{"Written by":"Brent Hendricks","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#article","isPartOf":{"@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/"},"author":{"name":"Brent Hendricks","@id":"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442"},"headline":"BASH Script &#8211; Guess My Number","datePublished":"2014-12-26T15:00:28+00:00","dateModified":"2016-07-28T16:45:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/"},"wordCount":1766,"commentCount":1,"publisher":{"@id":"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442"},"image":{"@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#primaryimage"},"thumbnailUrl":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg","articleSection":["Technical"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/","url":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/","name":"BASH Script - Guess My Number - Brent&#039;s World","isPartOf":{"@id":"https:\/\/www.catracing.org\/hendrb\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#primaryimage"},"image":{"@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#primaryimage"},"thumbnailUrl":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg","datePublished":"2014-12-26T15:00:28+00:00","dateModified":"2016-07-28T16:45:43+00:00","breadcrumb":{"@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#primaryimage","url":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg","contentUrl":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2014\/12\/v64_users_guide-181x300.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.catracing.org\/hendrb\/bash-script-guess-number\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.catracing.org\/hendrb\/"},{"@type":"ListItem","position":2,"name":"BASH Script &#8211; Guess My Number"}]},{"@type":"WebSite","@id":"https:\/\/www.catracing.org\/hendrb\/#website","url":"https:\/\/www.catracing.org\/hendrb\/","name":"Brent&#039;s World","description":"Your weekly dose of the life of Brent!","publisher":{"@id":"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.catracing.org\/hendrb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442","name":"Brent Hendricks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2019\/05\/Brent-Sitting-portrait-2.jpg","url":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2019\/05\/Brent-Sitting-portrait-2.jpg","contentUrl":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2019\/05\/Brent-Sitting-portrait-2.jpg","width":4480,"height":6720,"caption":"Brent Hendricks"},"logo":{"@id":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2019\/05\/Brent-Sitting-portrait-2.jpg"},"sameAs":["http:\/\/www.catracing.org","https:\/\/www.facebook.com\/Brents-World-912767498915017"],"url":"https:\/\/www.catracing.org\/hendrb\/author\/hendrb01\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p43ojH-eJ","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/posts\/913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/comments?post=913"}],"version-history":[{"count":0,"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/posts\/913\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/media?parent=913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/categories?post=913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/tags?post=913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}