[PLUG] sed command line script help

Paul Heinlein heinlein at attbi.com
Fri Nov 8 23:28:43 UTC 2002


On Fri, 8 Nov 2002, Bruce Kingsland wrote:

> I've been reading the docs, and I'm just getting more confused with
> sed. I want to extract the inet address from "ifconfig ppp0" to patch
> into an html doc for upload to my constant web space page.
> 
> What to do with the data after it's gathered is relatively easy, I
> think; but getting the data is another matter.
> 
>   inet addr:192.168.0.177  Bcast:192.168.0.255  Mask:255.255.255.0
> 
> Turning the above into:
> 
>   <A HREF=http://192.160.0.177> Ongoing Work In Progess </A>

#!/bin/bash

MYIP=$(/sbin/ifconfig | \                                                              
       grep -A 4 ppp0 | \
       awk '/inet/ {print $2}' | \
       sed -e s/addr://)

echo "<a href=\"http://$MYIP/\">blah</a>"

--Paul Heinlein <heinlein at attbi.com>





More information about the PLUG mailing list