cid wrote:...only if you can tell us IN ENGLISH (words of two syllables or less) just what possible use that 'equation' has...
...
...
..
Searching for certain patterns in text. e.g. say you wanted to find all IP addresses in a server log file. You could use
'(([0-9]{1,3}\.){3}[0-9]{1,3}'
i.e.
( # group
([0-9]{1,3}) # 1 to 3 numeric digits
\. # a literal dot
) # end group
{3} # must occur three times
[0-9]{1,3} # 1 to 3 numeric digits (again)
That will probably turn up things other than IPs if used on a log file, but it narrows a search down considerably. And it gets better - you can combine it with some other UNIX tools. Say you have a firewall that prints "DROPPED" to the log whenever it drops a packet. You want to find out which IPs have been pounding your firewall with the most attacks. You could create a chain of commands, like this:
- Code: Select all
grep DROPPED /var/log/messages | egrep -o '(([0-9]{1,3})\.){3}[0-9]{1,3}' | sort | uniq -c | sort -g
i.e.
"Find the string DROPPED in the log file"
"Find strings that look like IPs, and show only those strings"
"Sort the addresses"
"Show only unique addresses, prefixed with how many times they occur"
"Sort them again, by numeric value"
And the IPs at the bottom will be the ones with the most dropped packets... Assuming, at least, that the firewall doesn't print out some other information that throws off the search. One of the rules of regular expressions is that you have to know your data.
pumpkinpi wrote:Could you tell that was what it meant just by looking at it?
Hah, I wish... Usually I have to sound them out, so to speak.