X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_bin%2Ffind-text;fp=usr_bin%2Ffind-text;h=0000000000000000000000000000000000000000;hb=c08b156abb0b2b1b1335cb1ada0c08758553238b;hp=1cdbfba4f7fd7debe021abb6bf0e360df9ff0f0e;hpb=b0c3e5ff760f99d6ff7721852bc1a0d73c5ea201;p=grml-scripts.git diff --git a/usr_bin/find-text b/usr_bin/find-text deleted file mode 100755 index 1cdbfba..0000000 --- a/usr_bin/find-text +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/perl -s -# Written By Shamir Biton , 27/08/2001 -# This script can search for text pattern in text file only - -use Cwd; # to use internal perl libreary -sub ScanDirectory -{ - my ($workdir) = shift; - my ($startdir) = &cwd; # $startdir will get the current directory value - - # This part of code take the list of names from $workdir and place it in @names array - - chdir($workdir) or die "Unable to enter dir $workdir:$!\n"; - opendir(DIR,".") or die "Unable to open dir $workdir:$!\n"; - my @names = readdir(DIR) or die "Unable to read dir $workdir:$!\n"; - closedir(DIR); - - # - foreach my $name (@names) - { - next if ($name eq "."); - next if ($name eq ".."); - next if ($name eq "lost+found"); - - if (-d $name) - { - &ScanDirectory($name); - next; - } - - if (-T $name) # only if it is text file - { - # print ("Checking $name..\n"); - $NofTimes = 0; - open(FILENAME,$name); - - while() - { - - if (/$wordTOfind/i) # key word to search - { - $NofTimes +=1; - } - } - - close(FILENAME); - if ($NofTimes > 0) - { - print ("Found in $workdir/$name [$NofTimes Times]\n"); - } - - } - } - - chdir($startdir) or die "Unable to change dir $startdir:$!\n"; -} - -my ($defaultdir) = &cwd; -printf("Enter root path: [$defaultdir] "); -$userdir = ; -chomp $userdir; - -if (! $userdir eq "") -{ - while (! -d $userdir) - { - printf("Wrong Directory name, Please Enter Valid path name:"); - $userdir = ; - chomp $userdir; - } -} -printf("Enter Text To seach: "); -$wordTOfind = ; -chomp $wordTOfind; - -if ($userdir eq "") - { - &ScanDirectory(".") - } -else - { - print $userdir ; - &ScanDirectory($userdir); - - } -