Every now and then, a friend of mine sends me choice bits of Unix scripting
which I occasionally translate into scsh for comparison. Below I append the
latest example, courtesy Barak Pearlmutter.
-Olin
;;; Copy IN to OUT, prefixing each line with a timestamp,
;;; or, as we say in AWK,
;;; awk '{"date '"'"'+%b %e %T'"'"'" | getline d;
;;; close("date '"'"'+%b %e %T'"'"'"); print d, $0}'
;;;
;;; Quiz: why is the close() necessary?
;;; -Olin
;;; May 1997
(define (add-date in out)
(while (not (eof-object? (peek-char in)))
(format out "~a ~a\n"
(format-date "~b ~d ~H:~M:~S" (date)) ; E.g., "Sep 3 22:43:11"
(read-line in))))
|