title: Passing a port number to lsof in a shell function
body: <p>I wrote an alias in my bash profile to help me kill rogue rails server processes that don't cleanly close. This alias works well.</p>
  
  <pre><code>alias kill3000="lsof -i tcp: 3000 -t | xargs kill -9 | echo 'killed processes on port 3000'"
  </code></pre>
  
  <p>I wanted to make it more general purpose, for frameworks that work on other ports. I tried to make a similar function, so I could pass the port number as a variable, but I get an error. The function I wrote looks like this...</p>
  
  <pre><code>function killproc (){
      "lsof -i tcp:$1 -t | xargs kill -9 | echo 'killed processes on port $1'"
  }
  </code></pre>
  
  <p>However, when I run "killproc 3000", I get the following error:</p>
  
  <pre><code>lsof: unacceptable port specification in: -i tcp:
  </code></pre>
  
  <p>I'm struggling to understand the problem, I appreciate any help.</p>