remove Blank Lines at End of a Text File

This topic contains 4 replies, has 3 voices, and was last updated by  Nithun Damodaran 3 years ago.

  • Author
    Posts
  • #19050

    Nithun Damodaran
    Participant

    Am trying to copy contents from a text file to another file and it crates an empty line at the end of the file every time.

    Using PS v 3 and tried most of the available methods/one liners in the web, Any thoughts ?

    # Enable Dashboard

    $EnData = gc C:\DB\urls_EnableMon.tsv
    sc C:\DB\urls.tsv $EnData

  • #19051

    Don Jones
    Keymaster

    So... why not just use Copy-Item?

  • #19053

    Nithun Damodaran
    Participant

    My Bad!! That thought didn't strike me 🙁 Was busy breaking my head with copying contents in the file.

    Thanks you so much Don , You are truly inspiring !!

  • #19056

    I've recently stumbled upon the extra linefeed in textfiles created with powershell and found a nice solution for that on Stack Overflow

  • #19057

    Nithun Damodaran
    Participant

    @gilbert

    I have tried that and somehow it didnt work

You must be logged in to reply to this topic.