plan9port/bin/psu

42 lines
463 B
Text
Raw Permalink Normal View History

2003-10-13 18:25:28 +00:00
#!/bin/sh
flag=''
if [ "x$1" = "x-a" ]
then
flag=-a
shift
fi
case $# in
0)
2005-01-04 21:15:35 +00:00
user=$USER
2003-10-13 18:25:28 +00:00
;;
1)
user=$1
;;
*)
echo 'usage: psu [-a] [user]' 1>&2
exit 1
esac
2005-10-19 03:15:30 +00:00
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]
}
}
'