I want to get the top PID and Command which is taking the CPU > 90% on the server. I want the CPU% in a variable. I have tried it using the below ps command.ps -eo pid,cmd,%cpu --sort=-%cpu | head -2  PID CMD                         %CPU  987 dd if=/dev/zero of=/dev/nul 63.6I am trying it using AWK but It's getting me with the wrong information as it is showing dd command as a different column.Any way to get the cpu %
How to get the column name with a specific string?
shell script;awk
The following command will give you the %CPU:ps -eo pid,cmd,%cpu --sort=-%cpu | head -2| tail -1 | awk '{print $NF}'tail -1 - will provide the last line, which hold the actual numberawk 'print $NF}' will print the last element in the that line