Author Posts

July 6, 2016 at 4:00 am

Hi,
I have 5 log files, i need all log files data to one file.

I used the below command:
Get-Content .\*.txt | Out-File .\Combined.txt

It's working fine. But the data has no line space. For example: combined.txt is like below:
Aggregation Start Time – 2016-07-03 22.30.00
Aggregation End Time – 2016-07-03 23.30.57
Time taken for whole process – 3657330
Aggregation Start Time – 2016-07-02 22.30.00
Aggregation End Time – 2016-07-02 23.52.02
Time taken for whole process – 4922671
Aggregation Start Time – 2016-07-01 22.30.00
Aggregation End Time – 2016-07-01 23.51.51
Time taken for whole process – 4911916
Aggregation Start Time – 2016-06-29 22.30.00
Aggregation End Time – 2016-06-29 23.46.46
Time taken for whole process – 4606865
Aggregation Start Time – 2016-06-30 22.30.00
Aggregation End Time – 2016-06-30 23.51.52
Time taken for whole process – 4912036

I need a line space after Time taken for whole process.

-Kalyan

July 6, 2016 at 1:11 pm

$files = Get-ChildItem \\path\to\log*.txt
foreach ($file in $files) {
Add-Content -Value (Get-Content $file),"`n" -Path \\path\to\combinedlogs.txt}

July 7, 2016 at 6:24 am

Thanks.

I tried the below as-well & it worked.
Get-ChildItem '.\logresults*.txt' | %{ `
Get-Content $_.Name | Out-File .\Combined.txt -Append
"—".toString() | Out-File .\Combined.txt -Append
}

-Kalyan