title: "grep -v" weird behavior
body: <p>I'm trying to make sure my script only runs once at a time, but im running into weird behavior with inverting grep.</p>
  <p>My Code:</p>
  <pre><code>echo &quot;Current Pid: $$&quot;
  # Output &quot;Current Pid: 5387&quot;
  echo &quot;Process Count: $(pgrep -c -f &quot;$0&quot;)&quot;
  # Output: Process Count: 2
  
  if [ &quot;$(pgrep -c -f &quot;$0&quot;)&quot; -gt 1 ]
  then
      echo All Pids
      pgrep -f &quot;$0&quot;
      # Output &quot;4978, 5387&quot;
  
      echo Pids Current
      echo &quot;$(pgrep -f &quot;$0&quot; |&amp; grep -F $$)&quot;
      # Output &quot;5387&quot;
  
      echo Pids Inverted
      echo &quot;$(pgrep -f &quot;$0&quot; |&amp; grep -Fv $$)&quot;
      # Output &quot;4978, 5394&quot;
  
      # processPidsToKill=&quot;$(pgrep -f &quot;$0&quot; |&amp; grep -Fv $$)&quot;
  
      # for processPid in $processPidsToKill; do
      #     echo &quot;Killing `basename &quot;$0&quot;` $processPid&quot;
      #     kill &quot;$processPid&quot;
      # done
  fi
  </code></pre>
  <p>Can someone tell me what im doing wrong?
  Where does the new Pid come from when im using &quot;grep -v&quot;?</p>