1#!/usr/bin/perl -w 2# 3# Copyright (C) 2012, 2017: Unicode, Inc. and others. 4# License & terms of use: http://www.unicode.org/copyright.html 5# 6##################################################################### 7# Name : find_textfiles # 8# Full path : /home/umesh/bin/find_textfiles # 9# Type : Perl Script. Needs Perl 5. # 10# Description : Finds the text files under a directory # 11# Prunes CVS directories if -nocvs is provided # 12# Prunes RCS directories if -norcs is provided # 13# Prunes SCCS directories if -nosccs is provided # 14# Author : Umesh Nair (umesh@google.com) # 15# # 16#-------------------------------------------------------------------# 17# Maintenance Block: # 18# Date Changed by Description # 19# ---- ---------- ----------- # 20# May 2000 Umesh Nair Initial version of the script # 21# Mar 2002 Umesh Nair Added -h option # 22# May 2008 Umesh Nair Added -nosvn and -novc # 23# # 24##################################################################### 25 26use strict; 27use File::Find; 28 29my ($skipCvs, $skipRcs, $skipSccs, $skipSvn, $skipVc, $skipEclipse) = (0, 0, 0, 0, 0); 30my $help = 0; 31 32while ((defined $ARGV[0]) and ($ARGV[0] =~ /\A\-/)) { 33 my $option = shift; 34 chomp $option; 35 ($skipCvs = 1) if ($option =~ /nocvs/); 36 ($skipSccs = 1) if ($option =~ /nosccs/); 37 ($skipSvn = 1) if ($option =~ /nosvn/); 38 ($skipVc = 1) if ($option =~ /novc/); 39 ($skipEclipse = 1) if ($option =~ /noeclipse/); 40 ($help = 1) if ($option =~ /h/); 41} 42 43if ($help) { 44 exec "pod2man $0 | nroff -man |". ($ENV{"PAGER"} || 'more -s'); 45} 46 47if (@ARGV == 0) { 48 find (\&wanted, '.'); 49} else { 50 find (\&wanted, @ARGV); 51} 52 53sub wanted { 54 unless (($skipVc and (/\.vcproj$/ or /\.vcxproj$/ or /\.sln$/ or /\.dsp$/ or /\.dsw$/ or /\.filters$/)) 55 or ($skipEclipse and (/\.project$/ or /\.classpath$/ or /\.prefs$/ or /\.launch$/))) { 56 print "$File::Find::name\n" if (-f and -T ); 57 } 58 ($File::Find::prune = 1) 59 if ( 60 ($skipCvs and /^CVS$/) or 61 ($skipRcs and /^RCS$/) or 62 ($skipSccs and /^SCCS$/) or 63 ($skipSvn and /^\.svn$/) 64 ); 65} 66 67__END__ 68 69=head1 NAME 70 71find_textfiles - Finds the text files under a directory 72 73=head1 SYNOPSIS 74 75find_textfiles [C<-nocvs>] [C<-norcs>] [C<-nosccs>] [C<-nosvn>] [C<-novc>] [C<-noeclipse>] [ dir1 [ dir2 ] .... ] 76 77find_textfiles [C<-h>] 78 79=head1 DESCRIPTION 80 81This script recursively searches the specified directories (current 82directory if no parameter is passed) for text files, and lists the 83filenames on the standard output, one file per line. 84 85The directories named 'CVS', 'RCS' and 'SCCS' may be skipped by 86specifying the switches -nocvs, -norcs and -nosccs respectively. 87 88=head1 OPTIONS 89 90=over 4 91 92=item C<-h> 93 94Displays this help document. 95 96=item C<-nocvs> 97 98Prunes all directories named 'CVS' and everything under that. 99 100=item C<-norcs> 101 102Prunes all directories named 'RCS' and everything under that. 103 104=item C<-nosccs> 105 106Prunes all directories named 'SCCS' and everything under that. 107 108=item C<-nosvn> 109 110Prunes all directories named '.svn' and everything under that. 111 112=item C<-novc> 113 114Excludes all VC++ files, i.e., *.vcproj, *vcxproj, *.dsw, *.dsp, *.filters. 115 116=item C<-noeclipse> 117 118Excludes all Eclipse files, i.e., .project, .classpath, *.prefs, *.launch. 119 120=back 121 122=head1 SEE ALSO 123 124find_binaries 125 126=head1 AUTHOR 127 128Umesh Nair, 2000. 129 130=cut 131 132