Results 1 to 5 of 5
Quickest command to parse the IP address from a Received: header?
Surely there's a really obfuscated way to do this using sed, I bet.
For the uninitiated, the Received: syntax...
...
- 09-24-2007 #1Banned
- Join Date
- Dec 2002
- Location
- Texas
- Posts
- 242
Grab IP address from Received: header
Quickest command to parse the IP address from a Received: header?
Surely there's a really obfuscated way to do this using sed, I bet.
For the uninitiated, the Received: syntax...
Received: from FQDN (FQDN [10.20.30.40]) by FQDN blah, blah...
(As some might imagine, I'm working on tweaking Procmail recipes.)
- 09-24-2007 #2
Going strictly on the info you've provided, you could use:
Code:[mrbig ~]$ echo 'Received: from FQDN (FQDN [10.20.30.40]) by FQDN blah, blah...' | sed -e 's/.*\[//' -e 's/\].*//' 10.20.30.40
- 09-25-2007 #3Linux User
- Join Date
- Aug 2006
- Posts
- 458
Code:awk '/Received/{gsub(/\[|\]|\)/,"",$5);print $5}' file
- 09-25-2007 #4Just Joined!
- Join Date
- Aug 2007
- Posts
- 37
Code:while read y; do z=${y%]*}; echo ${z#*[}; done <file
- 09-25-2007 #5Banned
- Join Date
- Dec 2002
- Location
- Texas
- Posts
- 242
Great info, thanks folks!


Reply With Quote