[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: grep-ldif script



Daniel van Eeden wrote:
I wrote a script to grep ldif entries. It's useful for me, and maybe for
others. Should I try to get it included in the contrib dir of OL?

http://compukid.no-ip.org/dev/scripts/grep-ldif

Daniel van Eeden <daniel_e@dds.nl>

Is there an advantage to using Net::LDAP::LDIF that the below program is missing?


#!/usr/bin/perl
use strict; use warnings;
use Getopt::Std;

sub usage { print <<"_USAGE_" and exit; }
Usage: $0 [-d] [-v] search_string [ filenames ]
-d\t\t show only dn's
-v\t\t reverse grep
_USAGE_

my %opts=(); getopts("dv",\%opts);

my $search_string = shift or usage();

$/='';
while(<>) {
  print $opts{d} ? ( /^(.*\n)/ ) : $_
    if ( /:.*$search_string/o xor $opts{v} );
}
__END__

--
 John Borwick, Systems Administrator
       Wake Forest University
       Winston-Salem, NC, USA        | web  http://www.wfu.edu/~borwicjh

Attachment: signature.asc
Description: OpenPGP digital signature