#!/bin/bash # SIMPLE LIST HANDLING METHODS function plist.add () # insert plist numbered item { eval "function $1.set_$2 () { eval \"function $1.$2 () { echo '\$@' }\" }" $1.set_$2 $3 } function plist.show () # prints plist position item { $1.$2 } # ADDITIONAL HELPER FUNCTIONS function argp () # prints argument on position from string { local ARGN=$1 let ARGN++ echo "${!ARGN}" } # MAIN PROGRAM SECTION PSB=/bin/ps PSG=`${PSB} -A -o user:32,group:32, --no-headers ` # EXAMPLE: FILL THE LIST WITH ITEMS... PNU=0 while read PLN do let PNU++ plist.add $PNU user `argp 1 $PLN` plist.add $PNU group `argp 2 $PLN` done <<< "$PSG" # GET SORTED LIST OF ACTIVE USERS AND GROUPS COMBINATIONS PIN=0 while [ ! $PNU = $PIN ] do let PIN++ echo `plist.show $PIN user`:`plist.show $PIN group` done | sort -u | grep ${1:-^\.\*\$} exit 0 # vim:se nonu: