我有一個文件serviceOut_live.txt
本線:如何在同一行上強制輸出字符串?
[GC 1028838K->827912K(1305024K), 0.0311954 secs]
而且我希望將文件serviceOut_live.txt
轉換到另一個文件resul.txt
這種格式:
1028838 20131030165102
這是我的代碼:
$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
但結果是兩行:
1028838
20131030165102
而且我想要的結果在一條線:
1028838 20131030165102
我怎麼能這樣做呢?
非常感謝您的提示。 我認爲我沒有解釋我自己。 這是原始的文件: [GC 1028838K-> 827912K(1305024K),0.0311954秒] 我想要的結果在多行:
\ N =回車
1028838 20131030165102 \ n 1028822 20131030165103 \ n 1029999 20131030165107 \ n
我該怎麼做?