Re: script help with grep or regex ?

Jiří Baum <[email protected]>
Newsgroups gmane.org.user-groups.slug.general
Message-ID <[email protected]>
Hi,

> the page is reasonably constant (until any fixes?)

Yeah, that's always a danger...

> all the values I want are in a single 6000 char line, how do I break the
> 6000 char line into individual vaules, 'grep any_value file' gives me the
> whole 6000 chars ?

Several ways, probably the easiest is to use the --only-matching option
on grep. That way, it will only return the parts it matched.

For instance, you might write:
    grep -o '<foo class="bar">[0-9]*</foo>' file


Another way would be to use "sed" to add a newline at some reasonable
points, for instance at the beginning of each tag.


Finally, if you use Perl, you can just search for
    /<foo class="bar">([0-9]*)<\/foo>/
which will give you the parts you want directly in $1.


Jiri
-- 
Jiří Baum <[email protected]>
Sabik Software Solutions Pty Ltd
0413 183 117
http://www.baum.com.au/sabik
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.