On Wednesday 27 August 2008 15:25:02 Martin McCormick wrote:

>       The sed pattern matching system is interesting because I
> can think of several similar situations in which the data are
> there but there is no guarantee where on a given line it sits
> and grep or sed usually will pull in the whole line containing
> the desired data which means that one must further parse things
> to get what is wanted.

Hi Martin

Look at grep -o which only outputs the bit that matched the regexp. Using 
egrep, you can look for exactly two hex digits and a colon, repeated exactly 
five times, and followed by exactly two hex digits:

egrep -o '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}' inputfile

will parse inputfile and output all the MAC addresses it finds, one per line 
(if it finds more than one on an input line, it'll match them and print them 
on separate output lines), and nothing else.

Jonathan
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to