Hi,
I have 4 different files that contain the text below.
I need to Remove specific whitespace from the text and to find if there is a number that appears in more then one file and to print the output result to a new file that will includ lines with the following output:
1- The number
2- Letters thet appears next to the number
3- The name of the file that out put was taken from.
Example:
The text look like this in the files:
file 1 named PT1.txt:
IBN LG 25 1 03 08 077 437 1234 CPB GWLPOT
IBN LG 25 1 03 08 077 437 1111 IDL GWLPOT
file 2 named PT2.txt:
IBN LG 25 1 03 08 077 437 1113 PLO GWLPOT
IBN LG 25 1 03 08 077 437 2738 SB GWLPOT
IBN LG 25 1 03 08 077 411 2238 MB GWLPOT
file 3 named YK1.txt:
IBN LG 25 1 03 08 077 437 1113 SB GWLPOT
IBN LG 25 1 03 08 077 411 2738 SB GWLPOT
IBN LG 25 1 03 08 077 411 2338 MB GWLPOT
file 4 nemed YK2.txt
IBN LG 25 1 03 08 077 437 1113 PLO GWLPOT
IBN LG 25 1 03 08 077 437 2738 SB GWLPOT
IBN LG 25 1 03 08 077 437 2738 MB GWLPOT
The out put that I need to get is:
0774371113 SB | YK1.txt
0774371113 PLO | YK2.txt
I wrote a script for one file that delete some info from the lines and the out put look like this:
077 437 2738 CPB
077 437 2738 CPB
The script look like this:
#!/usr/bin/perl
$file = "PT1.txt";
open (IN, $file) || die "Cannot open file ".$file." for read";
@lines=<IN>;
open (OUT, ">", $file) || die "Cannot open file ".$file." for write";
foreach $line (@lines)
{
$line =~ s/\s\d{2}\s | \s\d{2}\s{6}//ig;
$line =~ s/\s\d{2}\s | \s\d{2}\s{6}//ig;
$line =~ s/\s\d{1}\s | \s\d{2}\s{2}//ig;
$line =~ s/\s\d{2}\s//ig;
$line =~ s/IBN|LG|GWLPOT//ig;
$line =~ s/\s{11}//ig;
print OUT $line;
}
close OUT;
please advice me with this issue,
Thank's in advance.
erezz 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.