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

Re: sed question



Erik Christiansen wrote:
...
> If the sed implementation of variable regexes proves problematic, then
> there's awk with its Dynamic Regexps. (Section 2.8 of the pdf manual
> floating about out there.)
>
> With its C-like syntax, it's less write-only than perl, perhaps because
> it is of the same vintage as sed. (And from the same stable.) It does
> admittedly tend to view its input stream a line at the time.

  i've used gawk in a different part of my script but not for 
pattern matching and replacement.  as this is an aside i won't
post a fully working fragment, but the following were pretty handy
for breaking a file apart so i could get at the chunks i needed
without having to write something more complicated to do it.

    gawk -v RS='+++\n' -v ORS= '{print > "zzzpart"NR}' zzzoldall
    gawk -v RS='\"\"\"\n' -v ORS= '{print > "zzzsumm"NR}' zzzoldall

the first one was for files with +++ marking the beginning and
ending of a header section and the second was for lines surrounded
by """ 's.


  songbird


Reply to: