title: How to grep the pidof bash in a shell script?
body: <p>I want to get the PID of bash and highlight it if it's in some textfile (assume it is). So when I'm typing this in my shell: </p>
  
  <pre><code>grep -o $(pidof bash) test.txt
  </code></pre>
  
  <p>it just works fine and gives me the desired output, the PID of bash.
  Then why is this script not working:</p>
  
  <pre><code>#!/bin/bash
  PID=$(grep -o $(pidof bash) test.txt)
  echo $PID
  </code></pre>
  
  <p>I only get some lines with:</p>
  
  <blockquote>
    <p>grep: xxx: file or directory not found</p>
  </blockquote>
  
  <p>xxx are random numbers, but usually the last one is the one I'm looking for.</p>
  
  <p>How do I achieve this and why is the above not working?</p>
  
  <p>Has this something to do with creating a new process by the shell when calling grep in the script?</p>
  
  <p>Thank you.</p>