Created
June 30, 2021 11:39
-
-
Save mrozo/03ae728a36f383ed7cae6ff9836196de to your computer and use it in GitHub Desktop.
joking cow
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
#!/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