Getting PID of process from bash shell command invoked from MONO C# app
Solution 1:
You need to escape the $
, like this
/bin/bash -c "ps -aef | grep -v grep | grep '{0}' | awk '{{print \$2}}'"
If you don't $2
gets interpreted too early by the shell and it ends up like this:
/bin/bash -c "ps -aef | grep -v grep | grep '{0}' | awk '{{print}}'"
and this will just will print the entire input line