sorting - 排序文件的大小是powershell中原始文件的两倍

标签 sorting powershell powershell-2.0 powershell-3.0 powershell-1.0

我有一个 powershell 脚本,它读取文件内容,对其进行排序并将输出写入新文件。以下是脚本:

获取内容 $inputFile |排序 > $sortedFile

文件中的输出已正确排序,但输出文件 ($sortedFile) 比输入文件 ($inputFile) 大两倍。注意:输出文件中没有重复或多余的行。

任何有关这方面的帮助或想法都会有所帮助。

最佳答案

最有可能的输入文件是 ascii编码,而使用重定向的默认输出是 unicode编码。

而不是使用 >作为重定向,您可以使用 out-file并指定编码。
get-content $inputFile | sort | out-file -encoding ASCII

关于sorting - 排序文件的大小是powershell中原始文件的两倍,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21374118/

相关文章:

bash - 在 BASH 脚本中按顺序读取文件

powershell - 何时评估数据部分?

powershell if-else 不遵循任何一个分支

PowerShell $PSVersionTable

replace - Powershell,你做了多少次替换?

arrays - 维护 bash 关联数组的插入顺序

sorting - Pandas 数据透视表嵌套排序

java - Java中具有数字名称的文件排序

azure - PowerShell 使用 Az.KeyVault 从 Azure Key Vault 导出 Pfx

powershell - 计算Active Directory用户