first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / users / find_user.sh
1 #!/bin/bash
2 if test $# -lt 1; then
3   echo $(basename $0): requires a user id for which to search.;
4   \exit 1;
5 fi
6 tempname="$(mktemp "$TMP/zz_trash.findme.XXXXXX")"
7 ps wuax | grep "$1[     ]*[0-9]" | sed -e '
8         /sed/d
9         /\/bin\/sh.*\/scripts\/find/d
10         /ps -uxg/d' >$tempname
11 # sed command eliminates field ambiguity for STAT field
12 cat $tempname| sed -e '/[RSD] N/s/[RSD] N/NUN/' |
13 awk '/^'$1'/ {
14         ORS=""
15         print "process #" $2, "started", $9 " "
16         if ($9 ~ /^[A-Za-z]/) {
17                 print $10, "with "
18         } else {
19                 print "with", $11 " "
20         }
21         print $12, $13, $14, $15, $16, $17 "\n"
22         }
23 ' | sort -k 1 -t\# -n
24 /bin/rm $tempname