The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 03-20-2009
ddrew78 ddrew78 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 8
Thanks to all who helped me on this. After much pain I decided to go a different route and instead appended the repeating string to it's previous line. Granted, that resulted in a few extra lines of code, but what the heck. Just an FYI, below is the code that ended up giving me the lines I was originally looking for.



open(FILE7, ">file7");
open(MYINPUTFILE, "file3");

while(<MYINPUTFILE>) {
chomp;
my $someword = "";
my $new-word = "";
if (/^someword/) {$someword = $_;while(<MYINPUTFILE>) {chomp;
if (/^new-word/){
print FILE7 "$someword $_";
print FILE7 "\n";}
last;
}
}
}
system "mv file7 file3";
system "dos2unix file3 > file7";
system "mv file7 file3";
system 'cat file3 | cut -d " " -f1-2 >>file0';
system "sort -n file0 >file1";
system "mv file1 file0";
system "sort file0 | uniq -u > file1";
system "mv file1 file0";