我正在使用 Powershell 和 7zip 提取 .tgz 档案。7zip 具有强制详细模式并污染我的屏幕。我只想显示错误消息。我已经用 FIND 删除了标准消息:
代码:
Write-Host "Extracting "$strArgument
# extract tgz to tar
& "$7z" x "-y" $strArgument | FIND /V "ing " | FIND /V "Igor Pavlov" | FIND /V "Processing " | FIND /V "Everything is Ok" | FIND /V "Folders: " | FIND /V "Files: " | FIND /V "Size: " | FIND /V "Compressed: " | FIND /V "Processing archive: "
# path to .tar
$strArgument = $strArgument.Replace(".tgz", ".tar")
$strArgument = $strArgument.Replace("i\data\", "")
# extract tar to file
#Write-Host $strArgument
& "$7z" x "-y" $strArgument | FIND /V "ing " | FIND /V "Igor Pavlov" | FIND /V "Processing " | FIND /V "Everything is Ok" | FIND /V "Folders: " | FIND /V "Files: " | FIND /V "Size: " | FIND /V "Compressed: " | FIND /V "Processing archive: "
这给了我一个带有很多空行的输出:
Extracting Q:\mles\etl-i_test\i\data\divider-bin.tgz
Extracting Q:\mles\etl-i_test\i\data\divider-conf.tgz
...
但是我只想:
Extracting Q:\mles\etl-i_test\i\data\divider-bin.tgz
Extracting Q:\mles\etl-i_test\i\data\divider-conf.tgz
如何从我的流中删除空白行?有强大的 FIND 开关吗?