|
|
egrep for any number of space and/or tabs
I need to egrep A records from a dns zone file... but there could be any number of spaces and/or tabs between the "IN" and the "A" on a line.
I've googled and tried various suggestions but am getting nowhere...
all tips and hints gratefully received
ian
|
|
0
|
|
|
|
Reply
|
iandiddamsorg (57)
|
6/29/2012 4:46:43 PM |
|
iandiddamsorg@googlemail.com wrote:
> I've googled and tried various suggestions but am getting nowhere...
egrep 'IN[ ]+A' dns.zone, where ' ' is a control-V<tab>
followed by a space? That doesn't work for you?
--
Brandon Hume - hume -> BOFH.Ca, http://WWW.BOFH.Ca/
|
|
0
|
|
|
|
Reply
|
hume.spamfilter (184)
|
6/29/2012 6:53:22 PM
|
|
hume.spamfilter@bofh.ca wrote:
> iandiddamsorg@googlemail.com wrote:
>> I've googled and tried various suggestions but am getting nowhere...
>
> egrep 'IN[ ]+A' dns.zone, where ' ' is a control-V<tab>
> followed by a space? That doesn't work for you?
I'd do this
egrep "IN[[:space:]]A" dns.zone
not all egreps support it, but at least you're not dealing with invisible
characters inside commands. [:space:] is a magic value that matches spaces
and/or tabs or any combination. you'd have to lookup how it's defined
though.
|
|
0
|
|
|
|
Reply
|
presence (537)
|
6/30/2012 5:27:01 AM
|
|
thanks guys... unfortunately neither suggestion works for me.
cheers anyway!
ian
|
|
0
|
|
|
|
Reply
|
iandiddamsorg (57)
|
7/2/2012 10:02:43 AM
|
|
iandiddamsorg@googlemail.com wrote:
> thanks guys... unfortunately neither suggestion works for me.
Then I'm not sure anyone can help you without a real example from the
zone file, because there's something weird going on.
You might try using perl.
--
Brandon Hume - hume -> BOFH.Ca, http://WWW.BOFH.Ca/
|
|
0
|
|
|
|
Reply
|
hume.spamfilter (184)
|
7/2/2012 12:55:20 PM
|
|
On Monday, July 2, 2012 1:55:20 PM UTC+1, (unknown) wrote:
> Then I'm not sure anyone can help you without a real example from the
> zone file, because there's something weird going on.
having done some more tests I totally concur. If I create a seperate text file with
a line
fred<space>IN<spaces>A<spaces>1.2.3.4
the above works fine - just not with the current zone files..
cheers for your time
Ian
|
|
0
|
|
|
|
Reply
|
iandiddamsorg (57)
|
7/2/2012 1:50:48 PM
|
|
On 07/ 2/12 01:55 PM, hume.spamfilter@bofh.ca wrote:
> iandiddamsorg@googlemail.com wrote:
>> thanks guys... unfortunately neither suggestion works for me.
>
> Then I'm not sure anyone can help you without a real example from the
> zone file, because there's something weird going on.
>
> You might try using perl.
>
Or nawk
--
Bruce Porter
"The internet is a huge and diverse community but mainly friendly"
http://blog.maui.co.uk/index.php/ytc/
There *is* an alternative! http://www.openoffice.org/
|
|
0
|
|
|
|
Reply
|
bdp8 (118)
|
7/2/2012 6:21:08 PM
|
|
iandiddamsorg@googlemail.com writes:
> thanks guys... unfortunately neither suggestion works for me.
Maybe "cat -v" would reveal separators other than space and tab?
Are you sure your command line quoted search string contained a real TAB
character?
-WBE
|
|
0
|
|
|
|
Reply
|
wbe (21)
|
7/2/2012 7:07:02 PM
|
|
On 2012-06-29, iandiddamsorg@googlemail.com <iandiddamsorg@googlemail.com> wrote:
> I need to egrep A records from a dns zone file... but there could be
> any number of spaces and/or tabs between the "IN" and the "A" on a line.
This can be done using egrep (see the other follow-ups) or by Perl which
also shipped with Solaris and which provides a more convenient syntax for
regular expressions with tons of extra features (see "perldoc perlre"
for a summary). If you want to extract just the A-records (and no AAAA
records), I suggest to use following line
perl -ne 'print if /\bIN\s+A\b/' zone
Option "-n" is similar to "-n" of sed (implicit loop over all input
lines but without an implicit print) and "-e" tells that the following
argument is the actual Perl script. The statement causes all input lines
to be printed that match the given regular expression:
\b word boundary (you won't match WIN here)
\s space character including space, tabs etc. but no newline
\s+ at least one space character
Andreas.
|
|
0
|
|
|
|
Reply
|
comp.unix.solaris1141 (1)
|
7/3/2012 2:19:25 PM
|
|
|
8 Replies
176 Views
(page loaded in 0.113 seconds)
|
|
|
|
|
|
|
|
|