Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just got Geektools, and I'm trying to get a shell geeklet to display the command top -F -R -o cpu in the same way that it is displayed in the terminal. Through Google, I found this command to show a bundle of system information:

uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/; NR; 5 {printf "CPU" $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'

This has way more CPU information than I want/need. I am hoping to replace the CPU information in the second command with the cleaner first one, but I don't know how to get it to display properly.

share|improve this question
I'm guessing that you want it exactly (or as close as possible) to the output from top? – daviewales Feb 13 '13 at 13:31
up vote 1 down vote accepted

Try ps aux. It displays a nice clean output sorted by cpu usage. If you want something even less cluttered, try

ps aux | awk '{print $3 "       " $11}';

To understand this command, just run ps aux, and look at the output. The variable $3 refers to the third column of the output. You can add or remove columns from GeekTool by adding or removing these variables from the command. The large amount of whitespace between the quotation marks just changes the spacing between the columns in the output.

If you want more options, check out the man page by typing man ps. (You can do this for top too. If you're wondering why I didn't suggest a modification using top, it is due to the following issues:

The problem with GeekTool is that it requires output from a command that is static. top can be made to give a static output by using top -l 1, but because it is only making one sample, it can't get the cpu usage. (It needs at least two for that.) You will notice that if you run top -l 1, your cpu usage will be displayed as 0. To rectify that, you can use top -l 2. However this displays the system usage twice, and only the second set of data is correct. This probably wouldn't be helpful for GeekTool. If you still really want to use top, you can try out the following command: top -l 2 -o cpu -R -stats cpu,command. However, it will only display the incorrect data, because it prints that first.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.