open Sys;; open Arg;; let lines = ref 4;; let follow = ref false;; let usage () = prerr_string ("Usage: "^argv.(0)^" [options] <file>"); prerr_newline (); exit 1;; let process_file filename = let desc = openfile filename [ O_RDONLY ] 0 in tail_lines desc !lines; if !follow then monitor desc (get_size desc) else close desc;; let mon_tail () = let options = [ ("-n", Int (fun k -> lines := k)," line number"); ("-f", Set follow, "follow appended") ] in parse options process_file "file name";; Printexc.print (handle_unix_error mon_tail) ();; |