title: Bash: If/Else statement in one line
body: <p>I am trying to check if a process (assume it is called <code>some_process</code>) is running on a server. If it is, then echo 1, otherwise echo 0.</p>
  
  <p>This is the command that I am using but it only works partially (more info below). Note that I need to write the script in one line.</p>
  
  <pre><code>ps aux | grep some_proces[s] &gt; /tmp/test.txt &amp;&amp; if [ $? -eq 0 ]; then echo 1; else echo 0; fi
  </code></pre>
  
  <p><strong>Note:</strong> The <code>[s]</code> in <code>some_proces[s]</code> is to prevent <code>grep</code> from returning itself.</p>
  
  <p>If <code>some_process</code> is running, then <code>"1"</code> gets echoed, which is fine. However, if <code>some_process</code> is not running, nothing gets echoed.</p>