Re: Any awk gurus on the list?
- From: Andres Perera <andres.perera@xxxxxxxx>
- Date: Fri, 20 Aug 2010 19:36:26 -0430
On Fri, Aug 20, 2010 at 12:42 PM, Paul Schmehl <pschmehl_lists@xxxxxxxxx> wrote:
I'm trying to figure out how to use awk to parse values from a string of
unknown length and unknown fields using awk, from within a shell script, and
write those values to a file in a certain order.
Here's a typical string that I want to parse:
alert ip
[50.0.0.0/8,100.0.0.0/6,104.0.0.0/5,112.0.0.0/6,173.0.0.0/8,174.0.0.0/7,176.0.0.0/5,184.0.0.0/6]
any -> $HOME_NET any (msg:"ET POLICY Reserved IP Space Traffic - Bogon Nets
2"; classtype:bad-unknown;
reference:url,www.cymru.com/Documents/bogon-list.html; threshold: type
limit, track by_src, count 1, seconds 360; sid:2002750; rev:10;)
There's really no need for tr nor sed in awk since it has sub().
#!/usr/bin/awk -f
BEGIN {
RS = ";"
}
$1 ~ /^sid:/ {
sub(/^[[:space:]]*/,"")
}
If you want to get other fields, making it into a function won't be
comfortable. You'd be better off using perl or lua in that case.
Andres
_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"
- References:
- Any awk gurus on the list?
- From: Paul Schmehl
- Any awk gurus on the list?
- Prev by Date: Re: anybody onlist know about KVM stuff?
- Next by Date: Re: anybody onlist know about KVM stuff?
- Previous by thread: Re: Any awk gurus on the list?
- Next by thread: Re: Any awk gurus on the list?
- Index(es):
Relevant Pages
|