let a cow tell you your fortune

2010-06-03 1 min read bash Linux
Here\’s something that I saw on commandlinefu yesterday. That sent me thinking about some command to have the cow file picked randomly 🙂 So, here\’s the original command from the commandlinefu:

let a cow tell you your fortune

    <td>
      <div class="text codecolorer">
        $ fortune | <a class="zem_slink freebase/en/cowsay" title="Cowsay" rel="homepage" href="http://www.nog.net/%7Etony/warez/cowsay.shtml">cowsay</a> -f tux
      </div>
    </td>
  </tr>
</table>

Let Tux bring the fortune cookie

\"commandlinefu.com\"

by David Winterbottom (codeinthehole.com)

\"\"

Now, for some fun

#!/bin/bash –
#===============================================================================

#          FILE:  fortune_cowsay.sh

#         USAGE:  ./fortune_cowsay.sh

#   DESCRIPTION:  Cowsay with random cow file.. 🙂

#       OPTIONS:  —
#  REQUIREMENTS:  —
#          BUGS:  —
#         NOTES:  —
#        AUTHOR:   (),
#       COMPANY:
#       VERSION:  1.0
#       CREATED:  06/01/2010 03:25:59 PM IST
#      REVISION:  —
#===============================================================================

array=( `ls -1 /usr/share/cowsay/ |tr &#8217;\n&#8217; &#8217; &#8217;` )
count=${#array}

random=$((RANDOM%count))

fortune |cowsay -f ${array[$random]%%.cow}<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://pittsburgh.metblogs.com/2010/04/26/big-bens-statement-fortune-cookie-version/">Big Ben&#8217;s statement…fortune cookie version (pittsburgh.metblogs.com) <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2010/05/12/get-the-most-favourite-commands-from-commandlinefu/">Get the most favourite commands from commandlinefu (amit-agarwal.co.in) <li class="zemanta-article-ul-li"><a href="http://teabreak.pk/some-questions-and-their-answers-178/35194/">Some questions and their answers… (teabreak.pk) <li class="zemanta-article-ul-li"><a href="http://bipolarsoupkitchen-stephany.blogspot.com/2010/05/fortune-cookie-wisdom.html">fortune cookie wisdom (bipolarsoupkitchen-stephany.blogspot.com) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/af1138ca-bee5-428a-8b0c-0263e1a4b095/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b94.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">

comments powered by Disqus
1