grep ip address from dhcpd.conf

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

grep ip address from dhcpd.conf

Postby sakimustafa » Sun Oct 11, 2009 9:06 am

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:

Postby lambda » Sun Oct 11, 2009 4:44 pm

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"?


Return to “Administration”

Who is online

Users browsing this forum: No registered users and 0 guests