I am trying to extract all text matching a particular pattern from files in the directory using PowerShell. However, for some reason it seems to loop indefinitely (output is an endlessly repeating set of the same results and the script never finishes). Please, can anyone give me a tip on what the problem is?
$input_path = 'C:\Users\*.txt'
$output_file = 'C:\Users\*.txt'
$regex = '[A-Za-z]+?_V[A-Z][A-Z0]?[A-Z]? [A-Za-z]+?_R[A-Z][A-Z]?V?'
select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $output_file