Re: file: extract data after finding string match



Niv wrote:
I currently read a set of (similar) files, containing only addresses
as @000000 etc, or byte data in successive lines. I copy the files to
a list and then strip out all data in the list(s) up to and including
a particular address, @300000.

The lists are later compared to a different list for exact match of
byte data.

However, is there a better way to read the file into the list(s) so I
don't have to replace the unwanted list data with null data?

file example:

@000000
F1
C4
54
34
65
@100000
43
56
76
87
@300000
F1
49
DE
E5

i.e. I want all the byte data from after the @300000 and nothing else
n my list(s).


set fd [open $myFileName]
set contents [read $fd]
close $fd

if {[regexp {@300000\s*(.*)} $contents fullmatch bytesIwant]} {
set myList [split $bytesIwant \n]
} else {
puts "Couldn't find address marker"
}


Bruce
.



Relevant Pages

  • Re: groff alternative?
    ... deprecated on FreeBSD.org lists. ... > I'm using NO_CXX in my make.conf to strip down the base system to ~50MB ... The only problem is that groff is missing if I don't ... to do modern BSD manuals. ...
    (freebsd-current)
  • Re: List shoes
    ... Shoes made of cutout pieces, of strips, ... SELVAGE <pieces having tightly woven lists which curl ... they were coming from Mr. Brown's house towards No. ... Border, edging, strip. ...
    (alt.usage.english)
  • Re: + deprecate-smbfs-in-favour-of-cifs.patch added to -mm tree
    ... on LKML it is expected to not strip CC lists and at least keep the ... one you are responding to. ... On Fri, 12 May 2006, Tom Rini wrote: ...
    (Linux-Kernel)
  • Re: Help: Tarzan Sunday Strip Info Needed
    ... > Tarzan Sunday strip artists. ... consolidate both lists. ...
    (rec.arts.comics.strips)
  • Re: OT: This Administration is starting to worry me.
    ... > Bruce wrote: ... If you trust that that is all the Gov't is ... a total loss for how those two totally unrelated lists could be abused by ... I can see some advertising use for the search terms (which is ...
    (rec.outdoors.rv-travel)