且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PowerShell从文本文件中删除空行

更新时间:2023-02-09 13:35:00

我在这里找到了一个不错的衬板>>

I found a nice one liner here >> http://www.pixelchef.net/remove-empty-lines-file-powershell. Just tested it out with several blanks lines including newlines only as well as lines with just spaces, just tabs, and combinations.

(gc file.txt) | ? {$_.trim() -ne "" } | set-content file.txt

有关该代码的一些注释,请参见原始文档.不错:)

See the original for some notes about the code. Nice :)