grep ip address from dhcpd.conf

Taking care of your Linux box.
Post Reply
sakimustafa
Lance Naik
Posts: 41
Joined: Sat Jan 13, 2007 1:36 pm
Location: Bangladesh
Contact:

grep ip address from dhcpd.conf

Post by sakimustafa »

Dear All,

How do I print only ip address from "fixed-address 10.0.1.25;" field.

Regards,
Saki
Best Regards,
SAKI
8801712764543
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Post by lambda »

you can use grep and sed:

Code: Select all

grep fixed-address /etc/dhcpd.conf |sed -e 's/^.* //' -e 's/;//'
just sed:

Code: Select all

sed -n 's/fixed-address \(.*\);/\1/p' /etc/dhcpd.conf
or perl:

Code: Select all

perl -nle 'print $1 if /fixed-address\s+(.*);/' /etc/dhcpd.conf
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
Post Reply