#!/bin/sh | |
flag='' | |
if [ "x$1" = "x-a" ] | |
then | |
flag=-a | |
shift | |
fi | |
case $# in | |
0) | |
user=$USER | |
;; | |
1) | |
user=$1 | |
;; | |
*) | |
echo 'usage: psu [-a] [user]' 1>&2 | |
exit 1 | |
esac | |
9 ps $flag | grep "^$user " | awk ' | |
BEGIN { min = 1000000 }; | |
{ | |
line[0+nline++] = $0; | |
n = length; | |
sub(/ +/, "", $0); | |
n -= length; | |
if(n < min) | |
min = n; | |
} | |
END{ | |
s = ""; | |
for(i=0; i<min-1; i++) | |
s = s " "; | |
for(i=0; i<nline; i++){ | |
sub(s, "", line[i]) | |
print line[i] | |
} | |
} | |
' |