Given a text file helloworld.txt containing the following line:
hello/world
The following sed
command will output the file contents with the line removed:
sed '\:^hello/world:d' helloworld.txt
However if the command is run as a System.Diagnostics.Process:
var process = new Process
{
StartInfo =
{
FileName = "sed",
Arguments = "'\\:^hello/world:d' helloworld.txt",
RedirectStandardOutput = true,
UseShellExecute = false
}
};
process.Start();
while (!process.StandardOutput.EndOfStream)
{
Console.WriteLine(process.StandardOutput.ReadLine());
}
process.WaitForExit();
Then the output is "hello/world" (i.e. the matching line is not removed).
Why is this?