So I have logged the history of Disk usage with a iotop > iohis.log

How can I view the file so it is formatted nicely and I can actually find the issue. I thought I could use the cat but it just fast worwards the whole text. =(. Could you give me any hints on how to view log file in a nice way?

  • I understand it is lame but I really need it. please help – simple Jan 27 '11 at 13:18
  • 2
    Step one: hold cat in hands. Step two: lift cat towards monitor.... – mattdm Jan 27 '11 at 14:35

You should not use cat. It just displays the whole file content and then it exits.

You have to use less. Also, you can combine grep and less to find some specific pattern. For example:

$ grep error /path/to/file | less

There are many other useful utilities available. Here are some: head, tail, and awk...

  • You can also search within less. Press / then type the regex you're looking for and press enter. Or less -p pattern to start the search from the command line. Also, less can scroll left and right if the output is wider than the terminal. Use -S to prevent wrapping (and -#1 for horizontal scrolling interval if you're on a fast terminal). – Dennis Williamson Jan 27 '11 at 16:21
  • You can also use ? to search backward. Use letter 'n' for next and letter 'N' for previous. – Khaled Jan 27 '11 at 16:53

Actually it's not the editor ... it's the way you "grab" it.

try to use batch mode (-b flag)

By default iotop (like top) are running in interactive mode.

  • Yes exactly as u said "interactive mode" - is there a way to simulate that interactive mode with a log file ? – simple Jan 27 '11 at 13:31
  • 1
    Wait ... what do you want to do ? You have the history of iotop (given with batch mode) and you want to see how it was evolved in time ? I 'm sorry but i 'm not completely sure that i understand what you want to do. – Nikolaidis Fotis Jan 27 '11 at 14:28
  • O well I just want to see the saved history without unrecognized characters – simple Jan 27 '11 at 18:29

Try less -R /path/to/iohis.log. Not perfect, but shows your log at least in a bit more readable form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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