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-l, --list=\$FILE list installed cookie files"
10 echo "\t-f=\$FILE, --file=\$FILE specify path to cookie file"
11 echo "\t-c=\$FILE, --cookie=\$FILE specify cookie file"
14 FILE="$(find /usr/share/fortune/ -type f -not -name '*.dat')"
15 while [ "$1" != "" ]; do
16 PARAM=`echo $1 | awk -F= '{print $1}'`
17 VALUE=`echo $1 | awk -F= '{print $2}'`
27 FILE=/usr/share/fortune/$VALUE
30 ls -1 /usr/share/fortune
34 echo "ERROR: unknown parameter \"$PARAM\""
53 fortunes[f] = fortunes[f] (length(fortunes[f])?"\n":"") $0
57 "date +%N" | getline time
59 print fortunes[int(rand() * f-2) + 2]