#!/bin/bash [ -f ~/.shakespeare.txt ] || { wget -O ~/.shakespeare.txt http://www.gutenberg.org/dirs/etext94/shaks12.txt } [ $1 ] || { echo "use: $(basename $0) " echo " $(basename $0) | $(basename $0) ..." exit } if [ -t 0 ]; then cat ~/.shakespeare.txt else cat - fi | tr -d "\015" | awk ' BEGIN { RS = "" } 0 < index(toupper($0),toupper(f)) { print "\n" $0 "\n" } ' f="$@" | less