Re: Using sed for multiline matching



laredotornado wrote:
On Dec 13, 12:35 pm, pk <p...@xxxxxxxxxx> wrote:
laredotornado wrote:
Ok, I give up. How do you use sed to do a multiline search given a
regular expression? I don't want to replace anything, just do a
search, much like grep. However, I'm to understand that grep only
searches one line at a time.
http://sed.sourceforge.net/sedfaq4.html#s4.23

after reading that, you'll might think of switching to another tool.

Do you have a suggestion, or even an example, or something else that
can match multi-lines given a regular expression? - Dave

Perl and awk will get the job done, but structural regular expressions is the simplest, cleanest model for this problem:

http://en.wikipedia.org/wiki/Sam_%28text_editor%29

If you need a non-interactive solution, just write the sam commands in some file and do:

$ sam -d file.txt < script.sam
.



Relevant Pages

  • Re: Fraudulent eBay listing
    ... O.K. I had not noticed that you were using plain grep, ... in egrep), * simply stands for "zero or more of the preceding ... Interpret PATTERN as an extended regular expression. ...
    (rec.crafts.metalworking)
  • Re: grep
    ... > Grep understands two different versions of regular expression syntax: ... > will output any line that contains cat OR dog OR bird or any combination. ... > Does anyone know how to construct a regular expression or in any way get ... > bird dog cat ...
    (Fedora)
  • USS regular expression
    ... the command has it is on AIX: ... the grep regular expression part I did using ' grep -E' no matter what ... combinations of regular expression I did base on the regular expression ... For IBM-MAIN subscribe / signoff / archive access instructions, ...
    (bit.listserv.ibm-main)
  • Re: Using sed for multiline matching
    ... laredotornado wrote: ... I'm to understand that grep only ... can match multi-lines given a regular expression? ...
    (comp.unix.shell)
  • Re: tips for writing regular expression interpreter/compiler?
    ... The dfa and nfa programs perform conversions as above. ... is grep, souped up to handle general boolean combinations (A intersect ... just represent a regular expression as you would ... Denoting the normal form of an expression A by NF, ...
    (comp.compilers)