LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   [bash] get user unknown ip from maillog (https://www.linuxquestions.org/questions/programming-9/%5Bbash%5D-get-user-unknown-ip-from-maillog-622165/)

kriezo 02-19-2008 02:05 AM

[bash] get user unknown ip from maillog
 
hi guys can u help here..
i can't find a command or any bash script to get ip for User unknown in my maillog file.

I had try to grep that line contain User unknown tag like this :

grep '[.][.][.] User unknown' maillog

but unfornately the ip was not in the line. Realized that the ip state one line after that.

Somebody please help..

slakmagik 02-19-2008 02:49 AM

man grep; grep -A, -C

kriezo 02-19-2008 04:48 AM

thanks digiot!!
no reason to preasure out till forgot the man page :-lol :p

anyway this is my edit command to get the ip :

grep -A 1 '[.][.][.] User unknown' maillog | egrep -o -e "[0-9]{2,3}\.[0-9]{2,3}\.[0-9]{2,3}\.[0-9]{2,3}"


All times are GMT -5. The time now is 05:41 PM.