Skip to content

Instantly share code, notes, and snippets.

@mrozo
Created June 30, 2021 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrozo/03ae728a36f383ed7cae6ff9836196de to your computer and use it in GitHub Desktop.
Save mrozo/03ae728a36f383ed7cae6ff9836196de to your computer and use it in GitHub Desktop.
joking cow
#!/usr/bin/env bash
URL='https://perelki.net/random'
function get_joke {
current_dir="$PWD"
cd /tmp
wget "$URL" --quiet
from_line="$(fgrep '<!-- POCZATEK -->' ./random -n | cut -d: -f1)"
to_line="$(fgrep '<!-- KONIEC -->' ./random -n | cut -d: -f1)"
joke="$(head -n $to_line ./random | tail -n $(($to_line - $from_line +1)) - | fgrep '<br />' | tr "\r" -d | sed 's/<br \/>/\n/g')"
rm random
cd "$current_dir"
echo "$joke"
}
get_joke | cowsay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment