Postfix: phantom hostname.

Kevin D. Clark clark_k at pannaway.com
Tue Jun 21 15:06:01 EDT 2005


Larry Cook writes:

> 	find /etc -type f -exec grep nebula {} /dev/null \;

A good suggestion, but doesn't skip binary files if they exist in
/etc.  I've written some bash shell aliases to help with this; these
are included below.

I would search for this thusly:

        txtfind /etc | xargs grep nebula

Regards,

--kevin


# Author: kevin d. clark

# Finds text files in the specified directories.  These use Perl's -T and -B
# tests.  Here's some relevant documentation from the perlfunc page:
#
#    The "-T" and "-B" switches work as follows.  The first block or
#    so of the file is examined for odd characters such as strange
#    control codes or characters with the high bit set.  If too many
#    strange characters (>30%) are found, it's a "-B" file, other-
#    wise it's a "-T" file.  Also, any file containing null in the
#    first block is considered a binary file. [....]  Both "-T" and
#    "-B" return true on a null file...
#
# Caveat programmer.
# 

# Find text files
txtfind () {
  if [ $# -eq 0 ] ; then
    txtfind .
  else
    perl -MFile::Find -e 'find(sub{print "$File::Find::name\n" if (-f && -T);}, @ARGV);' "${@}"
  fi
}

# Find DOS-formatted text files
dostxtfind () {
  if [ $# -eq 0 ] ; then
    dostxtfind .
  else
    perl -MFile::Find -e 'find(sub{ 
                                     $crlf = 0;
                                     if (($f = -f) && ($T = -T)) {
                                       @ARGV=($_);
                                       binmode(ARGV);
                                       (/\r\n/ && $crlf++) while(<>);
                                     }
                                     print "$File::Find::name\n" 
                                       if ($f && $T && $crlf);
                                   }, @ARGV)' "${@}"
  fi
}

# Find binary files
binfind () {
  if [ $# -eq 0 ] ; then
    binfind .
  else
    perl -MFile::Find -e 'find(sub{print "$File::Find::name\n" if (-f && -B);}, @ARGV);' "${@}"
  fi
}


-- 
GnuPG ID: B280F24E                     And the madness of the crowd
alumni.unh.edu!kdc                     Is an epileptic fit
                                       -- Tom Waits



More information about the gnhlug-discuss mailing list