title: How to get only process ID in specify process name in Linux?
body: <p>How to get only the  process ID for a specified process name in Linux?</p>
  <pre><code>ps -ef|grep java
  test 31372 31265  0 13:41 pts/1    00:00:00 grep java
  </code></pre>
  <p>Based on the process id I will write some logic. So how do I get only the process id for a specific process name.</p>
  <p>Sample program:</p>
  <pre><code>PIDS= ps -ef|grep java
  if [ -z &quot;$PIDS&quot; ]; then
  echo &quot;nothing&quot;
  else
  mail test@domain.example
  fi
  </code></pre>