Thread Sorting processes (6 answers)
Opened by Gast at 2006-11-15 19:06

Gast Gast
 2006-11-15 19:06
#8961 #8961
Hello Guys,

i see a lot of experts here, so i hope, you will help me to lose my homework:

I have to print in linux terminal 10 processes which are most wasteful for CPU at the time. The print should be refreshed every second. I found a command: ps -eo pid,comm,%cpu which gives me a list: ID TASK %CPU usage

I would really please you to help me sort this list...

Code: (dl )
1
2
3
4
5
6
7
8
#!/usr/bin/perl

@table=`ps -eo pid,comm,%cpu`;
# print "@tabela";

@tableedited=split(/ +/,"@table");

#print "@tableedited";


How should i go on?

Thanks in advance boys!

View full thread Sorting processes