[sf-lug] Learning regular expressions, sed(1), ...

jim jim at systemateka.com
Sun Feb 17 09:27:11 PST 2013




    Thanks for isolating this tppic, too. 
    Seems to me that while  sed  doesn't support 
variables, we pretty much always use  sed  as a 
command via the shell, often in a shell script, 
and the need for variable data can often be 
performed by the shell and passed to  sed  as 
arguments for each call. Maybe not all problems 
can be addressed in that way, but a lot of them. 
    (Just sticking my nose out in case someone 
sees a way to whack it for fun.) 




On Sun, 2013-02-17 at 01:56 -0800, Michael Paoli wrote:
> Well, regarding that example[1], I've covered some stuff on regular
> expressions before, e.g. [2].  And I've certainly also covered a fair
> bit on sed(1), e.g. [3].  It happens that sed fills a very interesting
> niche.  Yes, sed has BREs[4][2], but notably ... well, as I've described
> it before[3]:
> < Useful stuff to keep in mind with sed.  It doesn't have variables.  One
> < can however use the pattern space, and the hold space.  That, along with
> < how those spaces can generally be manipulated and how one can deal with
> < embedded newlines in those spaces, etc., that's essentially as close as
> < sed comes to having variables (perhaps think of it as a pair of stacks
> < or arrays).
> <
> < Also, sed doesn't have highly generalized flow control.  It does however
> < have unconditional and limited conditional branching, and command
> < grouping, and label for points branched to.
> <
> < So, for things approaching slightly more generalized programmatic
> < (generally editing) tasks with sed, one can track state via conditionals
> < and branches, and what one has in the hold and/or pattern space.
> 
> Oh, and yes, folks have actually written games in sed(1), e.g. [5].
> 
> references/excerpts/footnotes:
> 1. http://linuxmafia.com/pipermail/sf-lug/2013q1/009840.html
> > From: jim <jim at systemateka.com>
> > Date: Wed, 06 Feb 2013 09:09:45 -0800
> 
> >     I want to note to anyone learning regular
> > expressions that at bottom is a really good
> > sed  example.
> 2. http://www.rawbw.com/~mp/unix/regular_expressions/
> 3. news:d85eb83f.0407302303.634ae761 at posting.google.com
> https://groups.google.com/forum/#!msg/comp.unix.questions/BEhuf25NVB4/lAGh9MXZ2fgJ
> 4. http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
> 5. http://sed.sourceforge.net/#gamez
> 
> 
> _______________________________________________
> sf-lug mailing list
> sf-lug at linuxmafia.com
> http://linuxmafia.com/mailman/listinfo/sf-lug
> Information about SF-LUG is at http://www.sf-lug.org/






More information about the sf-lug mailing list