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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.