Combining multiple log files

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Venkata Kalyan Venkata Kalyan 2 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #45904
    Profile photo of Venkata Kalyan
    Venkata Kalyan
    Participant

    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

    #45966
    Profile photo of random commandline
    random commandline
    Participant
    $files = Get-ChildItem \\path\to\log*.txt
    foreach ($file in $files) {
    Add-Content -Value (Get-Content $file),"`n" -Path \\path\to\combinedlogs.txt}
    
    #46053
    Profile photo of Venkata Kalyan
    Venkata Kalyan
    Participant

    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

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.