On Sat, 1 Apr 2006, Sick Twist wrote:
> From: Eben King <eben1@tampabay.rr.com>
> Date: Sat, 1 Apr 2006 14:49:51 -0500 (EST)
>
>> On Sat, 1 Apr 2006, Sick Twist wrote:
>>
>>> I am trying to write a script that parses an unknown IP address from a
>>> page of HTML, compares the IP address to a file and overwrites the file if
>>> the saved IP address is different.
>>
>> sed -n '/ [1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]* /s/^.*
>> \([1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\) .*$/\1/p' <
>> file.html > address
>
> I don't need to create HTML, just pull an IP address out of it. Basically, I
> have a string with an IP address in the middle and I need to write a script
> that strips out just the IP address so that I can save it to a file. I forgot
> about sed but will definitely read up on it.
Yeah, that command should do it. It's basically
sed -n /expr/s/\(expr\)/\1/p
but expr is kinda messy. If I had a hankerin' to, I'd find a way to stick
expr in a variable. That would clean it up a lot.
-- -eben ebQenW1@EtaRmpTabYayU.rIr.OcoPm home.tampabay.rr.com/hactarEvery normal man must be tempted at times to spit upon his hands, hoist the black flag, and begin slitting throats. -- H.L. Mencken ----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:27:32 EDT