问题描述
我有以下代码来读取gawk并将其输出预测到文本文件(而不是使用shell-execute并使用>
进行此操作):
I have following code to read and redict the output of gawk to a textfile (instead of doing this with shell-execute and using >
):
var processStartInfo = new ProcessStartInfo
{
FileName = "gawk.exe",
Arguments = $@"-F ""{separator}"" -f ""{scriptFullFileName}"" ""{inputFullFileName}""",
UseShellExecute = false,
WorkingDirectory = workingDirectory,
RedirectStandardOutput = true,
CreateNoWindow = true
};
using (var process = Process.Start(processStartInfo))
{
using (var streamReader = process.StandardOutput)
{
var result = streamReader.ReadToEnd();
}
}
随后检查结果
,它总是以以下几行开头:
Inspecting result
afterwards, it always starts with the following lines:
从外壳执行 gawk.exe 时,这些行不存在.
Whereas executing gawk.exe from the shell, these lines are not present.
我在做什么错-或更妙的是,如何在不进行额外分析的情况下摆脱这两行?
What am I doing wrong - or better, how can I get rid of these 2 lines without additional parsing?
推荐答案
此问题与使用的gawk.exe版本有关,该版本为 3.1.6.2962 .使用 4.1.3 不会发生此问题.
This very issue is connected to the used version of gawk.exe, which was 3.1.6.2962.With 4.1.3 this problem does not occur.
这篇关于为什么重定向GAWK的StandardOutput总是在fstat之前添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!