I have a file serviceOut_live.txt
with this lines:
[GC 1028838K->827912K(1305024K), 0.0311954 secs]
And I want to convert the file serviceOut_live.txt
into another file resul.txt
with this format:
1028838 20131030165102
This is my code:
$input_path = 'c:\a\a\serviceOut_live.txt'
$output_file = 'c:\a\a\resul.txt'
$regex = '\[GC (\d{0,9})K->(\d{0,9})'
echo $(select-string -Path $input_path -Pattern $regex -AllMatches | % {
$_.matches[0].groups[1].value , $(get-date -format "yyyyMMddHHmmss")
} ) > $output_file
But the result is in two lines:
1028838
20131030165102
And I want the result in one line:
1028838 20131030165102
How could I do that?
Thank you very much for the tips. I think that I have not explained myself. This is the original file: [GC 1028838K->827912K(1305024K), 0.0311954 secs] And I want the result in multiple lines:
\n = carriage return
1028838 20131030165102\n 1028822 20131030165103\n 1029999 20131030165107\n
How could I do that?