title: Replacing text in log file if criteria match
body: <p>I have logfile1 that I am pulling the variables <code>$a</code>, <code>$up</code>, <code>$left</code>.  I have logfile2 that I am pulling the variables <code>$b</code>, <code>$down</code>, <code>$right</code>.  My goal is to replace any line in logfile1 with the data from logfile2 where <code>$a</code> = <code>$b</code>, <code>$up</code> = <code>$down</code>, and <code>$left</code> = <code>$right</code>, as long as all 3 match.  If any of the variables do not match, I would like to create a new line in logfile1 with the values of <code>$b</code>, <code>$down</code>, and <code>$right</code>.  Right now I have these logfiles in .log formats, but I could change them to CSV or any other file type if that would be easier.</p>
  
  <p>--Begin Edit</p>
  
  <p>Each variable is pulled from its respective log file using this basic format:</p>
  
  <pre><code>$logfilea = '\b\d{1,2}:\d{1,2}:\d{1,2}'
  select-string -Path $logfileone -Pattern $logfilea -AllMatches | % {$_.Matches} | %{$_.Value} | Set-Variable -Name a
   $logfileup = '([a-zA-Z] [a-zA_Z] ([a-zA_Z]))'
  select-string -Path $logfileone -Pattern $logfileup -AllMatches | % {$_.Matches} | %{$_.Value} | Set-Variable -Name up
   $logfileright = '([a-zA-Z] [a-zA_Z] ([a-zA_Z]))'
  select-string -Path $logfileone -Pattern $logfileright -AllMatches | % {$_.Matches} | %{$_.Value} | Set-Variable -Name up
  
  $logfileb = '\b\d{1,2}:\d{1,2}:\d{1,2}'
  select-string -Path $logfiletwo -Pattern $logfileb -AllMatches | % {$_.Matches} | %{$_.Value} | Set-Variable -Name b
   $logfiledown = '([a-zA-Z] [a-zA_Z] ([a-zA_Z]))'
  select-string -Path $logfiletwo -Pattern $logfiledown -AllMatches | % {$_.Matches} | %{$_.Value} | Set-Variable -Name down
   $logfileleft = '([a-zA-Z] [a-zA_Z] ([a-zA_Z]))'
  select-string -Path $logfiletwo -Pattern $logfileleft -AllMatches | % {$_.Matches} | %{$_.Value} | Set-Variable -Name left
  </code></pre>
  
  <p>Variables <code>$a</code> &amp; <code>$b</code> are Time Values.  <code>$up</code> and <code>$down</code> are two text objects with a 3rd object in parenthesis.  <code>$right</code> and <code>$left</code> are text objects within parenthesis.  All data matches in their patterns.  Thank you for your help.</p>