#!/usr/bin/env bash #=============================================================================== # # FILE: # USAGE: # DESCRIPTION: # REQUIREMENTS: # NOTES: # AUTHOR: C Hawley # CREATED: # #=============================================================================== # URL of the text file TEXT_FILE_URL="https://files.planethawleywood.com/quotes.txt" # Download the text file using curl and store it in a temporary file temp_file=$(mktemp) curl -s "$TEXT_FILE_URL" > "$temp_file" # Count the number of lines in the file num_lines=$(wc -l < "$temp_file") # Generate a random line number random_line=$(( (RANDOM % num_lines) + 1)) # Display the random line quote=$(sed -n "${random_line}p" "$temp_file") # cowsay and lolcat if available if [[ $(command -v cowsay) ]]; then if [[ $(command -v lolcat) ]]; then cowsay -f tux "${quote}" | lolcat else cowsay -f tux "${quote}" fi else echo "${quote}" fi # remove temp file rm $temp_file