LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 05-27-2016, 06:50 AM   #1
ift38375
Member
 
Registered: Dec 2012
Posts: 32

Rep: Reputation: Disabled
Command to search string in dhcpd.conf file in Centos 6.4


Hi,

We are running DHCP Server over Centos 6.4. All of ip address and MAC entries are stored in same file. Problem is that there are lots of entries and i want to find particular ip address or mac address.

Please tell me simple command to find with Procedure:

1. ip address = 192.168.13.23
2. MAC address = 45:r5:6y:88:qw:33


KS
 
Old 05-27-2016, 06:53 AM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Quote:
Originally Posted by ift38375 View Post
Hi,

We are running DHCP Server over Centos 6.4. All of ip address and MAC entries are stored in same file. Problem is that there are lots of entries and i want to find particular ip address or mac address.

Please tell me simple command to find with Procedure:

1. ip address = 192.168.13.23
2. MAC address = 45:r5:6y:88:qw:33
Pagers and editors have search function.
 
Old 05-27-2016, 07:10 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,119

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
You've been registered here 3.5 years and don't know how to do a simple search ?. Don't you take any notice ?.

"man grep"
 
Old 05-27-2016, 08:00 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
You could use egrep to search for both:

egrep -i "192.168.13.23|45:r5:6y:88:qw:33" <filename>

The -i tells it to ignore case (MAC addresses can have upper or lower case letters).

The double quotes show the beginning and end of what you're searching for.

The pipe sign is "or" when used with egrep like this to it says to search and find either the IP or the MAC (or both if both are there).
 
Old 05-27-2016, 08:06 AM   #5
ift38375
Member
 
Registered: Dec 2012
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
You've been registered here 3.5 years and don't know how to do a simple search ?. Don't you take any notice ?.

"man grep"

Hi Syg00,

This type of words demotivate users or newbie so please write after much thought and consideration.
As per your thinking , If any user from since 5 years on this portal then he should be expert in Linux.
I also aware from GREP command and tried but no luck.

It is not necessary that all registered users are totally involve in only Linux profile, I Have 7 years
Experience in IT field and working on many profiles ( like as Windows, SAN, SQL DB, ERP, and Linux ).

As i am seeing you are joined since 2003, can i expect from you to solve my problem ?


KS
 
Old 05-27-2016, 12:39 PM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,294
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
Quote:
Originally Posted by MensaWater View Post
You could use egrep to search for both:

egrep -i "192.168.13.23|45:r5:6y:88:qw:33" <filename>

The -i tells it to ignore case (MAC addresses can have upper or lower case letters).

The double quotes show the beginning and end of what you're searching for.

The pipe sign is "or" when used with egrep like this to it says to search and find either the IP or the MAC (or both if both are there).
Two other options which can come in handy with grep are -B and -A

(And for what it's worth egrep is also the same as grep -E)
 
Old 05-27-2016, 05:54 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
Also BE AWARE that CentOS 6.4 is unsupported and has been for some time
the only supported version in the 6 series is 6.7 ( or 6.8 if it has been released )

cent only supports the ONE current minor version
6.4 is missing about 1.5 YEARS of security updates

please double check the release version
Code:
cat /etc/redhat-release

as to finding the line of test
open the gedit search function

or

use grep with cat
Code:
 cat text_file_name | grep the_text_you_are_looking_for
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vlan tagging dhcpd.conf for second subnet in centos rootaccess Linux - Networking 5 02-01-2014 05:48 AM
"one-lease-per-client" option in ISC dhcpd dhcpd.conf file m4rtin Linux - Networking 3 09-27-2012 04:44 AM
How to re-invoke dhcpd after changes were made to dhcpd.conf file. Azazwa Linux - Newbie 3 03-30-2009 04:44 AM
giving search-string(s) from a file to linux "find" command Fond_of_Opensource Linux - Newbie 3 02-02-2009 06:14 PM
can't file dhcpd.conf vito_huang Linux - Networking 6 01-28-2005 07:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 12:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration