[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?


Daniel van Eeden <daniel_e@dds.nl>

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

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

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

my $search_string = shift or usage();

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

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

Attachment: signature.asc
Description: OpenPGP digital signature