General
cancel
Showing results for 
Search instead for 
Did you mean: 

how to check the output of top, from editor

SOLVED
Go to solution
Maaz
Valued Contributor

how to check the output of top, from editor

# top -d 1 -n 10 > top.out

# less top.out
"top.out" may be a binary file. See it anyway?

# vi top.out
its impossible/hard to read

# cat top.out | less
its impossible/hard to read

only
# cat top.out
is working

Regards
3 REPLIES
Matti_Kurkela
Honored Contributor
Solution

Re: how to check the output of top, from editor

By default, the top output contains terminal control codes that move the cursor around, updating various parts of the display.
When you use less or vi, the control codes are made visible/non-effective, causing a huge mess.

If you want to store the output of "top" to a file, add the -b option. With it, top won't use control codes and won't cut off the list at the terminal size.

Example:
top -b -d 1 -n 10 > top.out

# less top.out
it's easy to read, and contains more information!

MK
MK
Huc_1
Honored Contributor

Re: how to check the output of top, from editor

Is this better ?

$ grep "Maaz" top.out | sort

enjoy, life.

Jean-Pierre
Smile I will feel the difference
Dennis Handly
Acclaimed Contributor

Re: how to check the output of top, from editor

On HP-UX (but not linux) there is a "-f file" option the removes the cursor commands.