mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
41 lines
463 B
Bash
Executable file
41 lines
463 B
Bash
Executable file
#!/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]
|
|
}
|
|
}
|
|
'
|