Unix iTOps Tube

Wednesday, May 16, 2012


Hi im trying a GREP a varaiable which contains a file name and i search it in a list of .txt file and ifs its found the .txt file , it returns the name of the txt file name..the snippet im using is


foreach my $files (glob('*.txt'))


open(my $fh1, $files) or die("Unable to open '$files': $!");


if ( grep /$file/, <$fh1> )


$Sheet->Cells($row,$col+1)->{'Value'} = $files;

close ($fh1);

GREP is working fine but the issue is if $file contains apple.txt and when i search it in the text files the following patterns are getting matched _apple.txt ...

I want exact match or _ should be ignored ..i tried


grep -w /$file/

but nothing works....Any idea ...Thank u guys

No comments:

Post a Comment