为什么重定向 GAWK 的 StandardOutput 总是在前面加上 fstat
Why does redirecting StandardOutput of GAWK always prepend fstat
我有以下代码来读取 gawk 的输出并将其重定向到文本文件(而不是使用 shell-execute 和使用 >
执行此操作):
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();
}
}
之后检查 result
,它总是从以下几行开始:
fstat < 0: fd = 0
fstat < 0: fd = 2
而从 shell 执行 gawk.exe 时,这些行不存在。
我做错了什么 - 或者更好的是,我如何在不进行额外解析的情况下删除这两行?
这个问题与使用的 gawk.exe 版本有关,即 3.1.6.2962。
使用 4.1.3 不会出现此问题。
我有以下代码来读取 gawk 的输出并将其重定向到文本文件(而不是使用 shell-execute 和使用 >
执行此操作):
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();
}
}
之后检查 result
,它总是从以下几行开始:
fstat < 0: fd = 0
fstat < 0: fd = 2
而从 shell 执行 gawk.exe 时,这些行不存在。
我做错了什么 - 或者更好的是,我如何在不进行额外解析的情况下删除这两行?
这个问题与使用的 gawk.exe 版本有关,即 3.1.6.2962。 使用 4.1.3 不会出现此问题。