Remove blank lines from output?

BlackFox7

When I run this command, it returns the output with lots of blank lines.

Get-Host | Select Name, Version | Format-List

I tried using ExpandProperty but it still leaves me with one blank line at the end of the output, is there a way to remove the last blank line?

Get-Host | Select -ExpandProperty Name, Version | Format-List 
Raziel

If you really need the format that Format-List provides, then you can use Out-String and Trim() to get rid of empty lines:

Get-Host | Select Name,Version | Format-List | Out-String | ForEach-Object { $_.Trim() }

But, depending on your needs, it's probably easier to just use CSV or the JSON format for further processing (see ConvertTo-Json or ConvertTo-Csv).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Remove Blank Lines from XSL output

From Dev

Remove blank lines in powershell output

From Dev

How to remove initial blank lines from XmlWriter output?

From Dev

How to remove blank lines from HTML with HTMLAgilityPack?

From Dev

How to remove multiple blank lines from a file?

From Dev

How to remove multiple blank lines from a file?

From Dev

How to remove blank lines from HTML with HTMLAgilityPack?

From Dev

Remove spaces and blank lines from txt files

From Dev

if blank value in entire column then remove from output

From Java

Remove lines from a file corresponding to blank lines of another file

From Dev

remove lines from an output file from diff

From Dev

remove blank lines at the beginning

From Dev

Remove excessive blank lines

From Dev

how to remove the empty/blank lines from files that appears as @ from vi

From Dev

Remove Empty Lines From Powershell Output

From Dev

Remove blank lines from x axis in ggplot2

From Dev

Remove blank lines from plot geom_tile ggplot

From Dev

Unix Shell Script: Remove duplicates from line ignore blank lines

From Dev

RE: remove empty lines/blank strings from array in C

From Dev

How to remove blank lines from text file using powershell

From Dev

Scala: How to remove blank lines when reading text from file

From Dev

How to remove blank lines from a file (including tab and spaces)?

From Dev

Unix Shell Script: Remove duplicates from line ignore blank lines

From Dev

Remove blank lines from plot geom_tile ggplot

From Dev

RE: remove empty lines/blank strings from array in C

From Dev

remove blank lines from multiple files within a specific directory

From Dev

How to remove blank lines from text file using powershell

From Dev

remove blank lines from csv using shell script for oracle

From Dev

How do I remove blank lines from files?

Related Related

  1. 1

    Remove Blank Lines from XSL output

  2. 2

    Remove blank lines in powershell output

  3. 3

    How to remove initial blank lines from XmlWriter output?

  4. 4

    How to remove blank lines from HTML with HTMLAgilityPack?

  5. 5

    How to remove multiple blank lines from a file?

  6. 6

    How to remove multiple blank lines from a file?

  7. 7

    How to remove blank lines from HTML with HTMLAgilityPack?

  8. 8

    Remove spaces and blank lines from txt files

  9. 9

    if blank value in entire column then remove from output

  10. 10

    Remove lines from a file corresponding to blank lines of another file

  11. 11

    remove lines from an output file from diff

  12. 12

    remove blank lines at the beginning

  13. 13

    Remove excessive blank lines

  14. 14

    how to remove the empty/blank lines from files that appears as @ from vi

  15. 15

    Remove Empty Lines From Powershell Output

  16. 16

    Remove blank lines from x axis in ggplot2

  17. 17

    Remove blank lines from plot geom_tile ggplot

  18. 18

    Unix Shell Script: Remove duplicates from line ignore blank lines

  19. 19

    RE: remove empty lines/blank strings from array in C

  20. 20

    How to remove blank lines from text file using powershell

  21. 21

    Scala: How to remove blank lines when reading text from file

  22. 22

    How to remove blank lines from a file (including tab and spaces)?

  23. 23

    Unix Shell Script: Remove duplicates from line ignore blank lines

  24. 24

    Remove blank lines from plot geom_tile ggplot

  25. 25

    RE: remove empty lines/blank strings from array in C

  26. 26

    remove blank lines from multiple files within a specific directory

  27. 27

    How to remove blank lines from text file using powershell

  28. 28

    remove blank lines from csv using shell script for oracle

  29. 29

    How do I remove blank lines from files?

HotTag

Archive