I'm using this command to check all sshd processes and CPU USAGE and CMD for sshd deamon:
ps -C sshd -o %cpu,cmd
example of output:
%CPU CMD
0.0 sshd: root [priv]
0.0 sshd: aadmin@pts/1
After that i've used:
ps -C sshd -o %cpu,cmd | awk '!/%CPU/ {print $1, $3}'
Output:
0.0 root
0.0 aadmin@pts/1
To sort CPU USAGE and third line, what i want is to assign awk output var to have output like this for multiple processes and in separate lines.
CPU_USAGE=0.0 USER=root
CPU_USAGE=0.0 USER=aadmin@pts/1
I've tried to assign variable to awk with awk -v but without success
printtoprint "CPU_USAGE="$1, "USER="$3?To sort CPU USAGE and third line. Sort what? What third line?