guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep and sed in guile


From: Stefan Israelsson Tampe
Subject: Re: grep and sed in guile
Date: Tue, 27 Aug 2013 17:24:54 +0200

Nice!

Also scsh for guile can be used to get grep and sed functionality. The interesting thing is to try to 
design sed/grep like functionality that knows about scheme or C or whatever format in some clever way.
Usually sad and grep is good enough, but it is an interesting task never the less. My plan for know is to be able
to stream scheme source file and be able to sed them with an interface that is close to syntax-parse. That would be
really cool.

Cheers


On Tue, Aug 27, 2013 at 3:27 PM, Ludovic Courtès <address@hidden> wrote:
> 3) (sed m expr)
>
> This will print out on std output all lines not matched by m, if m is
> matched then that expr will make sure to print the correct way
>
> An example matcher is
>   m := (s-tr a b)
>
> which will replace a by b

FWIW Guix has a sed-like macro, called ‘substitute*’ [0].  Example:

  (substitute* "my-file.txt"
    (("^(.*) world$" _ first-word)
     (string-append "Hello (was: " first-word ") world\n")))

Ludo’.

[0] http://git.savannah.gnu.org/cgit/guix.git/tree/guix/build/utils.scm#n387




reply via email to

[Prev in Thread] Current Thread [Next in Thread]