1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
FMTSTR="%-16s%-10s%-20s%s\n"

now="$(date +%s)"

printf "$FMTSTR" NAME LINE "TIME ACTIVE (s)"

normalizetime(){
   echo $1 
}

printuser() {
    printf "$FMTSTR" "${2%@*}" "${6#*@}" "$(normalizetime ${3%@*})"
}

printusermosh() {
    printf "$FMTSTR" "${2%@*}" "mosh" "$(normalizetime ${3%@*})"
 
}

/pub/hammy/pkg/ps/ps -A -o pid,user=loneusernamehereallowplsowo,etimes,comm,args | while read -r line; do
    case "$line" in
        *sshd:*@pts/*)
            printuser $line
            ;;
	*mosh-server*new*)
	    printusermosh $line
	    ;;
    esac
done