It’s an extension method, so after importing the namespace (if different), you can use it like this:

var output = "ps aux".Bash();

output will contain the STDOUT of the result. Currently STDERR is not captured, but the above could easily be modified to do just that by changing the property RedirectStandardOutput and reading process.StandardError.

11 thoughts on “Running shell (bash) commands in .NET Core C#”

I am unable to run the linux command using dotnet core., followed the same steps but could not actually see the output of it.,
I am actually trying to run the commands to set the network configuration using c#.
Please help me in solving this to setup network configuration using c#.,the following is the code .