grep ip address from dhcpd.conf

Taking care of your Linux box.

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
sakimustafa
Lance Naik
 
Posts: 41
Joined: Sat Jan 13, 2007 1:36 pm
Yahoo Messenger: sakimumustafa@yahoo.com
Location: Bangladesh

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"?
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore


Return to “%s” Administration

Who is online

Users browsing this forum: No registered users and 2 guests

cron