<SNIP>
> I have a file with thousands of line  like :
> /abc/def/ijk/test.txt
> /pqr/lmn/test1.t
> I want to get the directory where the files test.txt and test1.txt are
> lying.
</SNIP>

Hi,
You can try the following:

#!/usr/bin/perl
open (IN,"<input_file") || die "Cannot open file: $!";
open (OUT,">output_file") || die "Cannot send the output: $!";

while (<IN>){
        print OUT $_ if(/test(1)?\.\w+/);
}

Some assembly required, batteries not included :)

HTH,

Senthil
+++++++++++++++++++++++++++++++++++++++++++++++
Senthil Kumar M
Senior Research Fellow,
Centre for DNA Fingerprinting and Diagnostics,
ECIL Road, Hyderabad 500 076
+++++++++++++++++++++++++++++++++++++++++++++++



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to