Implemented with Perl.
Print "INPUT FILE:";
$ FILE = ;
CHOMP ($ file);
Open (Hand, $ file) || DIE "can not open file";
Print "Input the String to Search:";
$ Str = ;
CHOMP ($ STR);
Print "The result: / n";
$ I = 0;
While ()
{
$ i ;
While (/ $ STR / G)
{
Print "line". $ I. ":". $ _;
}
}
Save as search.pl
C: /> perl search.pl
Input file: hello.txt
Input the string to search: hello
The result:
LINE2: this is a hello test.
Lien5: HelloWorld.
This program is run very fast.