newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Dmi on August 19, 2005, 04:16:43 PM

Title: better awk
Post by: Dmi on August 19, 2005, 04:16:43 PM
I wrote a small context to imitate awk operation

here is example:
(awk (read-file "/etc/passwd")
  (set 'FS ":")
  (rawk S
    ("^ro" (println (F 0) " " (F 2)))
    ("^daem" (println (F 2) " " (F 0)))))

is analog for:
$ awk -F: '
/^ro/{print $1,$3}
/^daem/{print $3,$1}
' /etc/passwd

here is the origin:

//http://en.feautec.pp.ru/SiteNews/awklsp
Title: Version update
Post by: Dmi on August 20, 2005, 09:58:39 AM
Small changes in documentation.

Added function (rcase) - like (case) but for string pattern match.
Title:
Post by: statik on August 20, 2005, 10:56:08 AM
awsome.
Title: Minor corrections
Post by: Dmi on August 20, 2005, 04:37:45 PM
corrected predefined value for field separator.



statik: I found, that description is bigger than the code :-)

But... aren't (rawk) and (rcase) useful?
Title:
Post by: pjot on August 21, 2005, 01:30:34 AM
Hi DMI,



My previous favorite language used to be AWK (now it's newLisp of course), so I find your experiments very interesting. For my job I still use AWK a lot. Now I can port some of my AWK stuff easily to newLisp.



Thanks!



Peter