Grep regex to capture ip socket without port -


i have in file following log:

aug 27 18:41:44 testlab nixc[27354]: 207416484 {10.20.21.106:52907 10.20.21.27:80} http traffic 

i extract ips example:

10.22.39.106 10.242.29.27 

i've tried

grep -e -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}.*[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' log 

i still

10.20.21.106:52907 10.20.21.27 10.20.21.106:52907 10.20.21.27 10.20.21.106:52907 10.20.21.27 10.20.21.106:52907 10.20.21.27 

maybe sed or cut trick?

thank in advance.

not sure if work grep:

\d{1,3}(?:\.\d{1,3}){3} 

i posted link site can test regex jsfidle aparently can't post links yet, google ;)

edited:

here ya go:

egrep -o '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}' /var/log/auth.log >> test.log 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -