2 # Fortune implementation in awk
6 echo "Usage: fortune [OPTIONS]
7 a simple POSIX sh/awk implementation of fortune
9 -h, --help show this help message
10 -l, --list list cookie files installed to /usr/share/fortune/
11 -f \$FILE, --file \$FILE specify full path to cookie file
12 -c \$FILE, --cookie \$FILE specify path to cookie file relative
13 to /usr/share/fortune/
17 FILE="$(find /usr/share/fortune/ -type f -not -name '*.dat')"
18 while [ "$1" != "" ]; do
28 FILE=/usr/share/fortune/$2
31 ls -1 /usr/share/fortune
35 echo "ERROR: unknown parameter \"$2\""
53 fortunes[f] = fortunes[f] (length(fortunes[f])?"\n":"") $0
57 "date +%N" | getline time
59 print fortunes[int(rand() * f-2) + 2]