Unix: How to kill a list of processes (PID) based on the lsof command?
<p>I would like to kill a list of PID that correlates to a process in a tcsh shell. I ran the following command:</p>
<pre><code>&gt; losf &lt;file&gt; | awk '{print($2)&quot;'
</code></pre>
<p>The command will show a list of PIDs.</p>
<blockquote>
<p>pid1</p>
<p>pid2</p>
<p>...</p>
</blockquote>
<p>I then ran the following command to kill those PIDs.</p>
<pre><code>&gt; kill -9 `lsof &lt;file&gt; | awk'{print($2)}'`
</code></pre>
<p>When the <code>kill</code> command is executed, the terminal just somehow hanged without killing any PID. I then had to revert to killing those PID one by one.</p>
<p>Therefore, is there a way to do what I intended to do as illustrated above? Thank you.</p>