title: Bash: grep pattern from command output
body: <p>I'm really new with bash, but it's one of the subjects on school. One of the exercises was:</p>
  
  <p><strong>Give the line number of the file "/etc/passwd" where the information about your own login is.</strong></p>
  
  <p>Suppose <code>USERNAME</code> is my own login ID, I was able to do it perfectly in this way:</p>
  
  <pre><code> cat /etc/passwd -n | grep USERNAME | cut -f1
  </code></pre>
  
  <p>Which simply gave the line number required (there may be a more optimised way). I wondered however, if there was a way to make the command more general so that it uses the output of <code>whoami</code> to represent the grep pattern, <strong>without scripting or using a variable</strong>. In other words, to keep it an easy-to-read one-line command, like so:</p>
  
  <pre><code> cat /etc/passwd -n | grep (whoami) | cut -f1
  </code></pre>
  
  <p>Sorry if this is a really noob question.</p>