• use awk remove irrelevant fields
    w | grep jeremy | awk '{print $5}'
  • awk is a full programming language, but we'll just use it to pull specific fields
  • awk breaks on spaces or tabs, but you can change that with -F
  • get username + GECOS from /etc/passwd
    awk -F: '{print $1, $5}' /etc/passwd
  • once you've trimmed data, you can eliminate duplicates with uniq
  • see how many different users own files in /usr/bin
    ls -al /usr/bin | awk '{print $3}' | uniq
  • sorting may be necessary to trim out all duplicates
  • NEXT
    PREVIOUS
    Master Index