On Tue, May 27, 2003 at 08:01:46PM -0500, Richard Kilgore wrote:
> On Tue, May 27, 2003 at 05:28:56PM -0500, Aaron Stout wrote:
> > Hi.
> >
> > I am trying to wright a quick script to get DNS nameserver entries from
> > dhcpd. While the script I have wrote works i would like to see how it
> > could be done with grep, awk or sed. Here is what I have.
> >
> > #!/bin/sh
> >
> > DNSSERVERS=`grep DNS /home/aaron/scripts/dhcpcd-eth0.info`
> > LIST=${DNSSERVERS//,/ }
> > newList=${LIST//DNS=/ }
> >
> > for serv in $newList; do
> > echo "nameserver $serv"
> > done
> >
> > Thanks
> > --
> > Aaron
>
> Try this:
>
> #!/bin/sh
>
> grep '^DNS=' /home/Aaron/scripts/dhcpcd-eth0.info | sed 's/DNS=/nameserver /'
That's wrong. I didn't know the format of dhcpcd-eth0.info.
I think I understand the expansion functionality you're using
now. Does the line in dhcpcd-eth0.info look like this?
DNS=<IP1>,<IP2>,<IP3>
If so, do this:
#!/bin/sh
grep '^DNS=' /home/aaron/scripts/dhcpcd-eth0.info \
| tr ',' '\n' \
| sed -e 's/DNS=//' -e 's/^/nameserver /'
--
Richard Kilgore
[EMAIL PROTECTED]
--
[EMAIL PROTECTED] mailing list