public static string BashCommand(string cmd)
{
var escapedArgs = cmd.Replace("\"", "\\\"");
var process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = "/bin/bash",
Arguments = $"-c \"{escapedArgs}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
}
};
process.Start();
string result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return result;
}
调用: BashCommand("date --set="2020-01-01 00:00:00"");
标签:00,01,string,NetCore,process,escapedArgs,修改,Linux,var From: https://www.cnblogs.com/Stay627/p/17195494.html