LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 07-15-2010, 01:33 PM   #1
gdanko
LQ Newbie
 
Registered: Feb 2007
Posts: 28

Rep: Reputation: 15
grep not working


I am trying to grep for A records in a bind zone file but I am failing.

I am trying: grep "\s+A\s+" db.domain.com

But there are no results. Am I doing something wrong?
 
Old 07-15-2010, 01:41 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
What is the intended logic?

e.g. are you trying to use "+" to mean "at least one of the preceding regex"? If so, you have to use "grep -E" or "egrep"

What is the intended meaning of the backslashes?
 
Old 07-15-2010, 01:53 PM   #3
gdanko
LQ Newbie
 
Registered: Feb 2007
Posts: 28

Original Poster
Rep: Reputation: 15
I am trying to find <whitespace>A<whitespace> to get a good idea of which is an A record.
 
Old 07-15-2010, 02:10 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
OK--I checked--it works with egrep.

Mark solved?
 
Old 07-15-2010, 02:17 PM   #5
gdanko
LQ Newbie
 
Registered: Feb 2007
Posts: 28

Original Poster
Rep: Reputation: 15
Absolutely.
 
Old 07-15-2010, 02:27 PM   #6
gdanko
LQ Newbie
 
Registered: Feb 2007
Posts: 28

Original Poster
Rep: Reputation: 15
Hmm I spoke too soon:


Code:
[root@ns1 ~]# cat test
hostname	IN	A	1.1.1.1
[root@ns1 ~]# egrep "\s+A\s+" test 
[root@ns1 ~]#

Last edited by pixellany; 07-15-2010 at 02:30 PM. Reason: added code tags
 
Old 07-15-2010, 02:32 PM   #7
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
How about trying this?

Code:
egrep '[[:space:]]+A[[:space:]]+' test
 
Old 07-15-2010, 02:35 PM   #8
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
I added code tags..

It works here:
Code:
[mherring@mystical play]$ cat ws
spaces:  the quick brown fox jumped over the lazy dog
tabs:   the     quick   brown   fox     jumped  over    the     lazy    dog
the quick brown fox jumped overthelazy dog

hostname        IN      A       1.1.1.1
[mherring@mystical play]$ egrep  "\s+A\s+" ws
hostname        IN      A       1.1.1.1
[mherring@mystical play]$

Last edited by pixellany; 07-15-2010 at 02:38 PM.
 
Old 07-15-2010, 02:36 PM   #9
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Hmm, funny.. It doesn't work for me as written above

Different grep versions?

I have:

Code:
sasha@reactor: egrep --version
GNU grep 2.5.4
 
Old 07-15-2010, 02:38 PM   #10
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
Code:
[mherring@mystical play]$ egrep --version
GNU grep 2.6.3
 
Old 07-15-2010, 02:49 PM   #11
gdanko
LQ Newbie
 
Registered: Feb 2007
Posts: 28

Original Poster
Rep: Reputation: 15
That worked for me.
 
Old 07-15-2010, 03:28 PM   #12
chaosless
LQ Newbie
 
Registered: Jul 2009
Location: Austin, Texas
Distribution: suse
Posts: 14

Rep: Reputation: 1
wouldn't it be simpler to use something like:

awk '$3=="A"{print;}' test
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
grep *.tpl is not working ravipat Linux - Newbie 3 07-03-2008 09:18 PM
I am learning sed / grep working and am stuck with a problem chris_looks Linux User Groups (LUG) 2 08-06-2007 02:31 PM
find | grep <pattern> not working duvalr Linux - Software 4 09-17-2006 05:07 AM
Regular Expression + not Working with grep scottwmackey Linux - General 2 06-21-2006 02:31 AM
-r parameter not working in grep learnfast Linux - Newbie 1 03-11-2005 05:17 AM


All times are GMT -5. The time now is 12:39 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration