Skip to content

Instantly share code, notes, and snippets.

@xoner
Created May 8, 2015 10:33
Show Gist options
  • Save xoner/bdbcc4df74c95e5e62df to your computer and use it in GitHub Desktop.
Save xoner/bdbcc4df74c95e5e62df to your computer and use it in GitHub Desktop.

Revisions

  1. xoner created this gist May 8, 2015.
    11 changes: 11 additions & 0 deletions random_cowsay_fortune
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #!/bin/bash

    # before running
    # apt-get install cowsay fortune

    COW_FILES_DIR="/usr/share/cowsay/cows/"
    COW_FILE_ORDER=$(( (RANDOM %51) + 2))
    RDM_COW_FILE=$(ls -l $COW_FILES_DIR | tail -n +$COW_FILE_ORDER | head -n 1 | awk '{print $9}')
    RDM_COW_PATH="$COW_FILES_DIR$RDM_COW_FILE"

    fortune | cowsay -f $RDM_COW_PATH