Filter Search Results
Hi,
I have been running a little server for a while, and i am wondering how many people have used it. The server creates crappy logfiles. I am trying to find the command which would allow me to print only the matching characters per line in the input file and follw each result with a line break. The results therefore should look something like this (a list of all ip addresses from a bunch of crappy logfiles): Code:
64.1.2.3 I was thinking about a program which matches something like this: Code:
[:digit:]\{1,3\}\.[:digit:]\{1,3\}\.[:digit:]\{1,3\}\.[:digit:]\{1,3\} The program is only supposed to print matches of the expression, not the entire line of its context. THANKS!! |
Try this:
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' /var/log/mylog.log or dmesg | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' you must have the slashes and single quotes. |
All times are GMT -5. The time now is 07:29 AM. |