summaryrefslogtreecommitdiff
path: root/localuserinfo
blob: b9b7075cf6df9159eb66280ca7428cd9fe77faa2 (plain)
  1. #!/bin/bash
  2. #
  3. # /usr/local/bin/localuserinfo
  4. # Copyright 2003 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: localuserinfo,v 1.1 2003-08-26 07:57:05 jonas Exp $
  7. #
  8. # Print real name and/or other info for user
  9. #
  10. # TODO: Options to print other info than realname
  11. #
  12. function get_fullname_field() { getent passwd $1 | awk -F: '{print $5}' | awk -F, '{print $1}'; }
  13. function get_roomnumber_field() { getent passwd $1 | awk -F: '{print $5}' | awk -F, '{print $2}'; }
  14. function get_other_field() { getent passwd $1 | awk -F: '{print $5}' | awk -F, '{print $5}'; }
  15. function get_groups() { groups $1 | sed -e 's/^.*: //' -e "s/\( \+\|^\)$1\( \+\|$\)/\1/"; }
  16. function get_domain() { echo $1 | egrep "^@[\.[:alnum:]-]+$" | sed -e 's/@//'; }
  17. function get_account() { echo $1 | egrep "^([\.[:alnum:]_-]+|\+)@($gid|$maildomain)?$" | sed -e 's/@.*//'; }
  18. for uid in $@; do
  19. get_fullname_field $uid
  20. done