title: See who is currently logged in and get their information from /etc/passwd
body: <p>I wanted to be able to see who is currently logged in into the server and then search <code>/etc/passwd</code> file based on their username and find their ID (column3) and full name (column5) and display them together.</p>
  
  <p>For example:</p>
  
  <pre><code>$ who    
  USER         TTY
  billyt     pts/2 
  $ cat /etc/passwd
  …
  billyt:x:10:100:Tom Billy:/home/billyt:/bin/bash
  …
  </code></pre>
  
  <p>My output should display his username, ID, and full name:</p>
  
  <pre><code>Username: billyt   ID: 10   FullName: Tom Billy
  </code></pre>
  
  <p>This is what I tried so far:</p>
  
  <pre><code>#!/bin/bash
  file="/etc/passwd"
  
  while IFS=: read -r f1 f2 f3 f4 f5 f6 f7
  do
          # display fields using f1, f2,..,f7
          echo "Username: $f1, UserID: $f3, FullName: $f5"
  done &lt;"$file"
  </code></pre>
  
  <p>I tried displaying fields I needed (f1, f3 and f5). Is this a good approach? Will I be able to simply search from <code>who</code> command, save the first field of who (username) to <code>who.txt</code> then search it from the file above?</p>