{"id":2055,"date":"2015-11-29T00:00:23","date_gmt":"2015-11-28T15:00:23","guid":{"rendered":"http:\/\/www.catracing.org\/hendrb\/?p=2055"},"modified":"2015-11-24T03:43:31","modified_gmt":"2015-11-23T18:43:31","slug":"fun-with-bash-scripts-randquote-v1-1","status":"publish","type":"post","link":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/","title":{"rendered":"Fun With BASH Scripts &#8211; Randquote v1.1"},"content":{"rendered":"<p>Some of the most popular posts on my blog have been my BASH scripting tutorials.\u00a0 I am not sure if anyone is actually typing them in and using them, but they do come to read them.\u00a0 One of the burdens of having successful posts, especially dealing with programing, is you feel compelled to come back and follow up on them.<\/p>\n<p>So while reading about\u00a0 \u201c20 Funny Commands of Linux or Linux is Fun in Terminal\u201d on Techmint ( <a href=\"http:\/\/www.tecmint.com\/20-funny-commands-of-linux-or-linux-is-fun-in-terminal\/\"><u>http:\/\/www.tecmint.com\/20-funny-commands-of-linux-or-linux-is-fun-in-terminal\/<\/u><\/a> ).\u00a0I stumbled upon &#8216;cowsay&#8217;\u00a0\u00a0amd had the wild idea that it would make a great upgrade \u00a0to my Random Quote script!<\/p>\n<p>First, let\u2019s start off with the simple question.\u00a0 What is Cowsay?\u00a0 Cowsay is a pearl script that will take text and output it inside a cow\u2019s cartoon speech bubble drawn with ASCII characters.\u00a0 Like This.<a href=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2056\" src=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg\" alt=\"Cowsay\" width=\"333\" height=\"137\" srcset=\"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg 333w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay-300x123.jpg 300w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><\/a><br \/>\nNow I know at this point there is a NIX guru out there jumping up and down, wanting to tell me that there is no need to modify my code at all, and this exercise is a waste of time, I could simply pipe the output of RandQuote to cowsay and be done with it.\u00a0 While on one hand this person would be correct, however there are 2 reasons to press on.\u00a0 The first being that due to the output being centered by the BASH Script, the output looks funny (Extra Spaces), second I want to be able to demonstrate how to write a BASH script that uses command line arguments.\u00a0 So get a fresh cup of coffee, pull up your chair, and stay awhile.<\/p>\n<p>The first thing we need to do is actually download and install the cowsay script, if you are running Linux in a GUI, simply go to the following URL ( <a href=\"http:\/\/www.melvilletheatre.com\/articles\/el7\/cowsay-3.03-14.el7.centos.noarch.rpm\"><u>http:\/\/www.melvilletheatre.com\/articles\/el7\/cowsay-3.03-14.el7.centos.noarch.rpm<\/u><\/a> )\u00a0to\u00a0download the file.<\/p>\n<p>If you are operating your system from the console or from a terminal you will need to use the wget command.<\/p>\n<p>If it is not installed use sudo yum install wget first, then copy the url above, then cd to your Downloads directory. Ie ~\/Downloads.\u00a0 If you do not have a downloads directory you can either use \/tmp (Though this is not considered best practice), or you can create the directory with the mkdir command.\u00a0 Anyways.\u00a0 Getting back on track, once you are sure your directory is set to the place you want to download cowsay to.<br \/>\nCopy the url above and enter sudo wget &lt;PASTE&gt;, you should end up with<br \/>\n<span style=\"color: #00ffff;\">$sudo wget <a style=\"color: #00ffff;\" href=\"http:\/\/www.melvilletheatre.com\/articles\/el7\/cowsay-3.03-14.el7.centos.noarch.rpm\"><u>http:\/\/www.melvilletheatre.com\/articles\/el7\/cowsay-3.03-14.el7.centos.noarch.rpm<\/u><\/a> .<\/span><\/p>\n<p>Once cowsay has been downloaded, we next need to install it using rpm.\u00a0 As we are still in the directory where cowsay was downloaded, simply perform an ls, and select and copy the filename, \u00a0<span style=\"color: #ffff00;\">cowsay-3.03-14.el7.centos.noarch.rpm<\/span> .\u00a0 Now issue the command<br \/>\n<span style=\"color: #ffff00;\">sudo rpm rpm \u2013ivh cowsay-3.03-14.el7.centos.noarch.rpm<\/span> . That\u2019s it!\u00a0 You now have cowsay installed.\u00a0 Now comes the hard part. Now we have to modify randquote to incorporate cowsay, hence making it v1.1.<\/p>\n<p>Lets test cowsay to make sure it is installed and working properly, at your shell prompt $ enter cowsay \u201cThe Quick Brown Fox Jumped Over The Lazy Dog.\u201d If everything installed correctly, you should be presented with the screen below.<\/p>\n<p><a href=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay_test.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2058\" src=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay_test.jpg\" alt=\"Cowsay_test\" width=\"966\" height=\"336\" srcset=\"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay_test.jpg 966w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay_test-300x104.jpg 300w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay_test-500x174.jpg 500w\" sizes=\"auto, (max-width: 966px) 100vw, 966px\" \/><\/a><\/p>\n<p>Now let\u2019s go ahead and actually add the necessary lines to randqoute.sh, if you actually have the script installed and running on your system, let\u2019s put it someplace where we can work on it, and not break the actual running copy.\u00a0 The documentation called for the script to run from \/opt\/randquote, and we will place a copy in a folder called dev under your home folder.\u00a0 If dev does not exist lets create it.\u00a0 At a shell prompt type $ mkdir ~\/dev &lt;ENTER&gt;<br \/>\nIf you perform a ls of ~\/ you should see dev listed.<\/p>\n<p>Lets perform the actual copy.\u00a0 So again at your shell prompt, type.$ sudo <span style=\"color: #ffff00;\">cp \/opt\/randquote\/randquote.sh ~\/dev\/randquote_v1.1.sh &lt;ENTER&gt;<\/span><\/p>\n<p>This will copy the file with the new filename randquote1.1.sh so we can easily differentiate between the two versions.\u00a0 We will also most likely need to change owners so we can edit the file without having to use SUDO all the time.<br \/>\n<span style=\"color: #ffff00;\">$ chown &lt;USERNAME&gt;\u00a0: &lt;GROUP&gt; ~\/dev\/randquote_v1.1.sh &lt;ENTER&gt;<\/span><\/p>\n<p>Let us now go into NANO, and edit the script.<\/p>\n<p><span style=\"color: #ffff00;\">$\u00a0nano ~\/dev\/randquote_v1.1.sh<\/span><\/p>\n<p>Add the following under the copyright message, &lt;CR&gt; Denotes Carriage Return.<br \/>\n<span style=\"color: #ffff00;\">#<\/span><br \/>\n<span style=\"color: #ffff00;\"># RandQuote v1.1 (C)22NOV2015 by Brent Hendricks<\/span><br \/>\n<span style=\"color: #ffff00;\"># Added the ability to display quotes through cowsay.<\/span><br \/>\n<span style=\"color: #ffff00;\"># cowsay is writen by Tomy Monroe (<a style=\"color: #ffff00;\" href=\"mailto:tomy@nog.net\"><u>tomy@nog.net<\/u><\/a>)<\/span><br \/>\n<span style=\"color: #ffff00;\">&lt;CR&gt;<\/span><br \/>\n<span style=\"color: #ffff00;\">COWSAY=0<\/span><br \/>\n<span style=\"color: #ffff00;\">&lt;CR&gt;<\/span><br \/>\n<span style=\"color: #ffff00;\">## Get Options<\/span><br \/>\n<span style=\"color: #ffff00;\">&lt;CR&gt;<\/span><br \/>\n<span style=\"color: #ffff00;\">while getopts &#8220;c&#8221; OPTION<\/span><br \/>\n<span style=\"color: #ffff00;\">do<\/span><br \/>\n<span style=\"color: #ffff00;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 case $OPTION in<\/span><br \/>\n<span style=\"color: #ffff00;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c)<\/span><br \/>\n<span style=\"color: #ffff00;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 COWSAY=1<\/span><br \/>\n<span style=\"color: #ffff00;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ;;<\/span><br \/>\n<span style=\"color: #ffff00;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0esac<\/span><br \/>\n<span style=\"color: #ffff00;\">done<\/span><br \/>\n<span style=\"color: #ffff00;\">&lt;CR&gt;<\/span><\/p>\n<p>Now cursor down to ## Read Quote from Quote file<\/p>\n<p>After sed -n &#8220;${RECORD},+5p&#8221; $QUOTATIONS &gt; $TEMP_QUOTATION<\/p>\n<p>Highlight and cut <span style=\"color: #ff0000;\">sed -e :a -e &#8220;s\/^.\\{1,${TERMWIDE}\\}$\/ &amp;\/;ta&#8221; -e &#8216;s\/\\( *\\)\\1\/\\1\/&#8217; $TEMP_$<\/span><\/p>\n<p>Then add the following.<\/p>\n<p>&lt;CR&gt;<br \/>\nif [ $COWSAY -eq 0 ]<br \/>\nthen<br \/>\nPaste the line you cut from above. \u2018<span style=\"color: #ff0000;\">sed -e :a -e &#8220;s\/^.\\{1,${TERMWIDE}\\}$\/ &amp;\/;ta&#8221; -e &#8216;s\/\\( *\\)\\1\/\\1\/&#8217; $TEMP_$\u2019<br \/>\n<\/span>else<br \/>\ncat &#8220;${TEMP_QUOTATION}&#8221; | cowsay<br \/>\nfi<\/p>\n<p>The rest of the file remains untouched.\u00a0 The entire file listing should look like this.<\/p>\n<p><span style=\"color: #ffff00;\">1\u00a0 #! \/bin\/bash<\/span><br \/>\n<span style=\"color: #ffff00;\">2<\/span><br \/>\n<span style=\"color: #ffff00;\">3\u00a0 # BASH script to display RANDOM QUOTE and center text depending on terminal width.<\/span><br \/>\n<span style=\"color: #ffff00;\">4\u00a0 # BASH script and quotations taken from CNET Amiga 2 AREXX PFILE<\/span><br \/>\n<span style=\"color: #ffff00;\">5\u00a0 # AMIGA Version Copyright 1992 Jim Selleck and Beverly James Products<\/span><br \/>\n<span style=\"color: #ffff00;\">6\u00a0 #<\/span><br \/>\n<span style=\"color: #ffff00;\">7\u00a0 # BASH Script (C)24MAY2015 by Brent Hendricks<\/span><br \/>\n<span style=\"color: #ffff00;\">8\u00a0 # Script and accompaning BLOG article (C) 2015 Brent Hendricks<\/span><br \/>\n<span style=\"color: #ffff00;\">9\u00a0 # Script and quotes are public domain, the accompaning BLOG may only be<\/span><br \/>\n<span style=\"color: #ffff00;\">used with permission<\/span><br \/>\n<span style=\"color: #ffff00;\">10\u00a0 # Contact brent.hendricks@catracing.org if you wish to republish the article.<\/span><br \/>\n<span style=\"color: #ffff00;\">11\u00a0 # Please visit Brent&#8217;s World @ www.catracing.org\\hendrb<\/span><br \/>\n<span style=\"color: #ffff00;\">12\u00a0 #<\/span><br \/>\n<span style=\"color: #ffff00;\">13\u00a0 # RandQuote v1.1 (C)22NOV2015 by Brent Hendricks<\/span><br \/>\n<span style=\"color: #ffff00;\">14\u00a0 # Added the ability to display quotes through cowsay.<\/span><br \/>\n<span style=\"color: #ffff00;\">15\u00a0 # cowsay is writen by Tomy Monroe (tomy@nog.net)<\/span><br \/>\n<span style=\"color: #ffff00;\">16<\/span><br \/>\n<span style=\"color: #ffff00;\">17\u00a0 COWSAY=0<\/span><br \/>\n<span style=\"color: #ffff00;\">18<\/span><br \/>\n<span style=\"color: #ffff00;\">19\u00a0 ## Get Options<\/span><br \/>\n<span style=\"color: #ffff00;\">20<\/span><br \/>\n<span style=\"color: #ffff00;\">21\u00a0 while getopts &#8220;c&#8221; OPTION<\/span><br \/>\n<span style=\"color: #ffff00;\">22\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 do<\/span><br \/>\n<span style=\"color: #ffff00;\">23\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 case $OPTION in<\/span><br \/>\n<span style=\"color: #ffff00;\">24\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c)<\/span><br \/>\n<span style=\"color: #ffff00;\">25\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 COWSAY=1<\/span><br \/>\n<span style=\"color: #ffff00;\">26\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ;;<\/span><br \/>\n<span style=\"color: #ffff00;\">27\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 esac<\/span><br \/>\n<span style=\"color: #ffff00;\">28\u00a0 done<\/span><br \/>\n<span style=\"color: #ffff00;\">29<\/span><br \/>\n<span style=\"color: #ffff00;\">30\u00a0 ## Get Terminal Width<\/span><br \/>\n<span style=\"color: #ffff00;\">31\u00a0 TERMWIDE=&#8221;$(tput cols)&#8221;<\/span><br \/>\n<span style=\"color: #ffff00;\">32\u00a0 ((TERMWIDE = TERMWIDE -3))<\/span><br \/>\n<span style=\"color: #ffff00;\">33<\/span><br \/>\n<span style=\"color: #ffff00;\">34\u00a0 ## Set file path<\/span><br \/>\n<span style=\"color: #ffff00;\">35\u00a0 QUOTATIONS=\/opt\/randquote\/quotations<\/span><br \/>\n<span style=\"color: #ffff00;\">36\u00a0 TEMP_QUOTATION=\/tmp\/temp_quotation<\/span><br \/>\n<span style=\"color: #ffff00;\">37<\/span><br \/>\n<span style=\"color: #ffff00;\">38\u00a0 ## Get number of quotations<\/span><br \/>\n<span style=\"color: #ffff00;\">39\u00a0 QUOTES=&#8221;$(cat $QUOTATIONS | wc -l)&#8221;<\/span><br \/>\n<span style=\"color: #ffff00;\">40\u00a0 ((QUOTES = QUOTES \/ 5))<\/span><br \/>\n<span style=\"color: #ffff00;\">41<\/span><br \/>\n<span style=\"color: #ffff00;\">42\u00a0 ## Pick a record<\/span><br \/>\n<span style=\"color: #ffff00;\">43<\/span><br \/>\n<span style=\"color: #ffff00;\">44\u00a0 RECORD=$(($RANDOM % $QUOTES * 5))<\/span><br \/>\n<span style=\"color: #ffff00;\">45<\/span><br \/>\n<span style=\"color: #ffff00;\">46\u00a0 ## Read Quote from Quote file<\/span><br \/>\n<span style=\"color: #ffff00;\">47\u00a0 sed -n &#8220;${RECORD},+5p&#8221; $QUOTATIONS &gt; $TEMP_QUOTATION<\/span><br \/>\n<span style=\"color: #ffff00;\">48<\/span><br \/>\n<span style=\"color: #ffff00;\">49\u00a0 if [ $COWSAY -eq 0 ]<\/span><br \/>\n<span style=\"color: #ffff00;\">50\u00a0 then<\/span><br \/>\n<span style=\"color: #ffff00;\">51\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0sed -e :a -e &#8220;s\/^.\\{1,${TERMWIDE}\\}$\/ &amp;\/;ta&#8221; -e &#8216;s\/\\( *\\)\\1\/\\1\/&#8217;<\/span><br \/>\n<span style=\"color: #ffff00;\">$TEMP_QUOTATION<\/span><br \/>\n<span style=\"color: #ffff00;\">52\u00a0 else<\/span><br \/>\n<span style=\"color: #ffff00;\">53\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cat &#8220;${TEMP_QUOTATION}&#8221; | cowsay<\/span><br \/>\n<span style=\"color: #ffff00;\">54\u00a0 fi<\/span><br \/>\n<span style=\"color: #ffff00;\">55<\/span><br \/>\n<span style=\"color: #ffff00;\">56\u00a0 ## Remove TEMP_QUOTATION scratch file<\/span><br \/>\n<span style=\"color: #ffff00;\">57\u00a0 # rm -f &#8220;${TEMP_QUOTATION}&#8221;<\/span><br \/>\n<span style=\"color: #ffff00;\">58 exit 0<\/span><br \/>\nWe should now be able to test version 1.1.\u00a0 make sure you are in the directory where v1.1 resides and at a shell prompt enter.<\/p>\n<p><span style=\"color: #ffff00;\">$ .\/randquote_v1.1.sh \u2013c<\/span><\/p>\n<p>If all worked out right in the end, you should see.<\/p>\n<p><a href=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Working_Randquote1.1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2059\" src=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Working_Randquote1.1.jpg\" alt=\"Working_Randquote1.1\" width=\"1014\" height=\"337\" srcset=\"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Working_Randquote1.1.jpg 1014w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Working_Randquote1.1-300x100.jpg 300w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Working_Randquote1.1-500x166.jpg 500w\" sizes=\"auto, (max-width: 1014px) 100vw, 1014px\" \/><\/a><\/p>\n<p>Let&#8217;s also do a quick test to determine if you can also generate the random quote without the output being piped through cowsay.<\/p>\n<p>At the shell prompt execute randquote without the -c option, like this.<\/p>\n<p><span style=\"color: #ffff00;\">$ .\/randquote_v1.1.sh<\/span><\/p>\n<p>You should then only see the normal randquote output.<\/p>\n<p><a href=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/06\/console_randquote.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1574\" src=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/06\/console_randquote-1024x216.jpg\" alt=\"console_randquote\" width=\"940\" height=\"198\" srcset=\"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/06\/console_randquote-1024x216.jpg 1024w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/06\/console_randquote-300x63.jpg 300w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/06\/console_randquote-500x105.jpg 500w, https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/06\/console_randquote.jpg 1536w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><\/a><\/p>\n<p>Once everything is tested me can replace randquote with v1.1<\/p>\n<p>At the shell prompt, let us first rename the original randquote so we retain a backup copy. To do this we use the move (mv) command.<\/p>\n<p><span style=\"color: #ffff00;\">$ sudo mv \/opt\/randquote\/randquote \/opt\/randquote\/randquote_v1.0 &lt;ENTER&gt;<\/span><\/p>\n<p>Now we move randquote_v1.1 from our dev directory, renaming it randquote. (Unless you want to keep the _v1.1 filename and change your login scripts.<\/p>\n<p>$ sudo mv ~\/dev\/randquote_v1.1 \/opt\/randquote\/randquote<\/p>\n<p>We are now finished, if you have entered randquote for the first time, you will also need to download the quotations file attachment. <span style=\"color: #00ffff;\"><a style=\"color: #00ffff;\" href=\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/06\/quotations.txt\">http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/06\/quotations.txt<\/a><\/span><\/p>\n<h3><span style=\"color: #3366ff;\">I would like to thank the following people whose blog\u2019s helped immensley with writing version 1.1<\/span><\/h3>\n<p>First I would like to thank Tomy Monroe who without cowsay, version 1.1 would not be possible.<\/p>\n<p>Second I would like to thank Avishek Kumar for writing the blog 20 Funny Commands of Linux or Linux is Fun in Terminal, <a href=\"http:\/\/www.tecmint.com\/20-funny-commands-of-linux-or-linux-is-fun-in-terminal\/\"><u>http:\/\/www.tecmint.com\/20-funny-commands-of-linux-or-linux-is-fun-in-terminal\/<\/u><\/a> . Who gave me the original idea.<\/p>\n<p>Last but not least, for showing me the light regarding the getopts statement, this wonderful blog tutorial by rsalveti, Bash: Parsing arguments with \u2018getopts\u2019 <a href=\"https:\/\/rsalveti.wordpress.com\/2007\/04\/03\/bash-parsing-arguments-with-getopts\/\"><u>https:\/\/rsalveti.wordpress.com\/2007\/04\/03\/bash-parsing-arguments-with-getopts\/<\/u><\/a><\/p>\n<h3><span style=\"color: #00ffff;\">I hope you enjoyed the blog, and please visit our forums, register and discuss this script, other Linux or technical topics, by visiting. <span style=\"color: #999999;\">www.catracing.org\/hendrb\/forums<\/span><\/span><\/h3>\n","protected":false},"excerpt":{"rendered":"<p>Some of the most popular posts on my blog have been my BASH scripting tutorials.\u00a0 I am not sure if anyone is actually typing them in and using them, but they do come to read them.\u00a0 One of the burdens <span class=\"excerpt-dots\">&hellip;<\/span> <a class=\"more-link\" href=\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/\"><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-2055","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>Fun With BASH Scripts - Randquote v1.1 - 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\/fun-with-bash-scripts-randquote-v1-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fun With BASH Scripts - Randquote v1.1 - Brent&#039;s World\" \/>\n<meta property=\"og:description\" content=\"Some of the most popular posts on my blog have been my BASH scripting tutorials.\u00a0 I am not sure if anyone is actually typing them in and using them, but they do come to read them.\u00a0 One of the burdens &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/\" \/>\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=\"2015-11-28T15:00:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"333\" \/>\n\t<meta property=\"og:image:height\" content=\"137\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/\"},\"author\":{\"name\":\"Brent Hendricks\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442\"},\"headline\":\"Fun With BASH Scripts &#8211; Randquote v1.1\",\"datePublished\":\"2015-11-28T15:00:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/\"},\"wordCount\":1433,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442\"},\"image\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg\",\"articleSection\":[\"Technical\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/\",\"url\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/\",\"name\":\"Fun With BASH Scripts - Randquote v1.1 - Brent&#039;s World\",\"isPartOf\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg\",\"datePublished\":\"2015-11-28T15:00:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#primaryimage\",\"url\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg\",\"contentUrl\":\"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.catracing.org\/hendrb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fun With BASH Scripts &#8211; Randquote v1.1\"}]},{\"@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":"Fun With BASH Scripts - Randquote v1.1 - 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\/fun-with-bash-scripts-randquote-v1-1\/","og_locale":"en_US","og_type":"article","og_title":"Fun With BASH Scripts - Randquote v1.1 - Brent&#039;s World","og_description":"Some of the most popular posts on my blog have been my BASH scripting tutorials.\u00a0 I am not sure if anyone is actually typing them in and using them, but they do come to read them.\u00a0 One of the burdens &hellip; Continue reading &rarr;","og_url":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/","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":"2015-11-28T15:00:23+00:00","og_image":[{"width":333,"height":137,"url":"https:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg","type":"image\/jpeg"}],"author":"Brent Hendricks","twitter_misc":{"Written by":"Brent Hendricks","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#article","isPartOf":{"@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/"},"author":{"name":"Brent Hendricks","@id":"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442"},"headline":"Fun With BASH Scripts &#8211; Randquote v1.1","datePublished":"2015-11-28T15:00:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/"},"wordCount":1433,"commentCount":0,"publisher":{"@id":"https:\/\/www.catracing.org\/hendrb\/#\/schema\/person\/abd5b294207e782562c7bb51e0a9e442"},"image":{"@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#primaryimage"},"thumbnailUrl":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg","articleSection":["Technical"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/","url":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/","name":"Fun With BASH Scripts - Randquote v1.1 - Brent&#039;s World","isPartOf":{"@id":"https:\/\/www.catracing.org\/hendrb\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#primaryimage"},"image":{"@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#primaryimage"},"thumbnailUrl":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg","datePublished":"2015-11-28T15:00:23+00:00","breadcrumb":{"@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#primaryimage","url":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg","contentUrl":"http:\/\/www.catracing.org\/hendrb\/wp-content\/uploads\/2015\/11\/Cowsay.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.catracing.org\/hendrb\/fun-with-bash-scripts-randquote-v1-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.catracing.org\/hendrb\/"},{"@type":"ListItem","position":2,"name":"Fun With BASH Scripts &#8211; Randquote v1.1"}]},{"@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-x9","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/posts\/2055","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=2055"}],"version-history":[{"count":0,"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/posts\/2055\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/media?parent=2055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/categories?post=2055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.catracing.org\/hendrb\/wp-json\/wp\/v2\/tags?post=2055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}