Last active
August 22, 2018 19:14
-
-
Save populov/89028ee3c6c4a2123697da8d2e509e33 to your computer and use it in GitHub Desktop.
Fortune + Cowsay with random cows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # First install fortune and cowsay: | |
| # see http://manpages.ubuntu.com/manpages/bionic/en/man6/cowsay.6.html | |
| # and http://manpages.ubuntu.com/manpages/bionic/man6/fortune.6.html | |
| # $ sudo apt-get install fortune cowsay | |
| # and some collection of fortunes. You can find available packages: | |
| # $ apt search fortunes | |
| # for example: | |
| # $ sudo apt-get install fortunes fortunes-off fortunes-ru | |
| # now run what.sh | |
| COWS=/usr/share/cowsay/cows | |
| cows="" | |
| for cow in $(ls -1 $COWS/*); do | |
| cows="$cows $(basename $cow | sed 's/.cow$//')" | |
| done | |
| cows=($cows) | |
| num_cows=${#cows[*]} | |
| cow="${cows[$(( RANDOM % num_cows))]}" | |
| fortune | cowsay -f $cow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment