0

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?

simple
  • 53
  • 1
  • 5

3 Answers3

2

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...

Khaled
  • 36,533
  • 8
  • 72
  • 99
  • 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
0

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.

Nikolaidis Fotis
  • 2,032
  • 11
  • 13
  • 1
    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
0

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

Janne Pikkarainen
  • 31,852
  • 4
  • 58
  • 81