2015-02-11 111 views
0

我的同事在線發現了這個Batch命令(Windows中的Powershell Command),我需要知道它用於輸出到文件的「編碼」。我知道它不是utf-8。下面是一個命令:PowerShell命令 - 這個輸出是什麼?

Select-String logfile.log -pattern "string pattern" | tee-object -filepath "output_file.txt" -append 

我的Windows版本爲Windows Server 2012 RC標準

回答

1

https://technet.microsoft.com/en-us/library/hh849937.aspx

Tee-Object兩者使用Unicode編碼時,將其寫入文件。因此,輸出可能無法在具有不同編碼的文件中正確格式化。要指定編碼,請使用Out-File cmdlet。

在PowerShell中找到命令Select-String

+0

對,謝天謝地。我使用了out-file -encoding UTF8。 – 2015-02-11 22:24:53