问题
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:
fstat < 0: fd = 0
fstat < 0: fd = 2
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?
回答1:
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.
来源:https://stackoverflow.com/questions/35067123/why-does-redirecting-standardoutput-of-gawk-always-prepend-fstat