0

This script will show the top 5 processes that are using the most CPU percentage. What i'd like to do is color the process that is the highest, which should be the first line. Does anyone know how to do this?

#!/bin/bash

COL_GREEN='\E[32;01m'

ps -eo user,pcpu,pid,cmd | sort -r -k2 | head -6
1
Contributor
1
Reply
2
Views
10 Years
Discussion Span
Last Post by krammer
0

Heh...just figured it out:

#!/bin/bash

COL_GREEN='\E[32;01m'

COMMAND=$(ps -eo user,pcpu,pid,cmd | sort -n -u -k2 | head -6 | sed '$!d')

echo -e "$COL_GREEN $COMMAND" ; tput sgr0
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.