2 # Fortune implementation in awk
6 echo "fortune -- a simple awk/POSIX sh implementation of fortune"
8 echo "\t-h --help show this help message"
9 echo "\t--file=\$FILE specify path to cookie file"
12 FILE="$(find /usr/share/fortune/ -type f -not -name '*.dat')"
13 while [ "$1" != "" ]; do
14 PARAM=`echo $1 | awk -F= '{print $1}'`
15 VALUE=`echo $1 | awk -F= '{print $2}'`
25 echo "ERROR: unknown parameter \"$PARAM\""
39 fortunes[f] = fortunes[f] (length(fortunes[f])?"\n":"") $0
43 "date +%N" | getline time
45 print fortunes[int(rand() * f) + 1]