removing blanks from file


  • I have a script that will get-content on a line-by-line text file for a list of servers. I need to remove blank lines, and lines that have blank spaces, as well as blank spaces after server names.

    So far I have:

    $oldlist = Get-Content $file | Where {$_ -ne ""} | ForEach-Object {$_.trim()} | Out-File ".\newfile.txt"
    $newlist = Get-Content ".\newfile.txt" | Where {$_ -ne ""}

    can this be accomplished in one line, and w/out creating a new text file?

    2012년 3월 2일 금요일 오전 6:58


모든 응답