Having a need to concatenate files and not having a decent command-line tool, I wrote:
;; cat
;; concatenate files
;; c:> cat file1 file2 file3 ... >stdout
;;
;; cat.make
;; (load {c:newlisplink.lsp})
;; (link {c:newlispnewlisp.exe} "cat.exe" "cat.lsp")
(map (fn (F) (write-line (read-file F))) (rest (main-args)))
(exit)
which seems to work pretty well. Is there a better sol'n?
Hello Sammo,
Very Lispy !! great... now i was thinking exactly the same this week
except for a tool called "tail" You dont happen to have one perhpas :-) ?
Newlisp is great for baking tools this way ;-) love it...
Regards...Norman.
How about this?
1) read the entire file whose name is (nth 1 (main-args))
2) parse into lines
3) use 'slice' to get last (nth 2 (main-args)) lines (assumes an integer)
4) join and print the result
;; tail
;;
(print (join
(slice
(parse (read-file (nth 1 (main-args))) "rn")
(- (integer (nth 2 (main-args)))))
"rn"))
(exit)
Seems to work!
yes thats a real nice tail alright ;-)
If your into a new adventure?
Try tailing continously a file :-)
im not sure if newlisp can do it, but i doubt that its not able to do it ;-)
Regards, Norman...