Under a UNIX shell, how can I get a similar effect to the watch
command, but with paging so that I can scroll around in the output if it takes up more than one screen?
In other words, I want a program that is to watch
what less
is to cat
.
As an example, lets say I wanted to watch the output of qstat
, I could use
watch qstat
to watch the output of qstat, but this can only shows the first screenful.
With a paging version of watch
, I would be able to move around in the output as it is still continuously updated by watch
. Is there any way to do this at the moment with existing utilities?
Rather than modifying the 'watch' command, use screen!
For example, let's say that you need to be able to see 300 lines of height and 100 characters of width and move around that. After starting screen, force the size thus:
Now start your watch command. You can then use
C-a <ESC>
to page around the display.Unfortunately, the display doesn't refresh while in copy mode. But if you want to adjust which section of the window you're viewing, the easiest way may be to rerun the height/width commands as by default your terminal shows the lower-right of the virtual window.
You can try this:
replace
vmstat
withqstat
and adjust thesleep
to your needs.Multitail: http://www.vanheusden.com/multitail/
Example:
Scroll back by press 'b' and page/arrow up/down.
OK, I've had a little go at a
watchless
function. It's a bit rough, and it doesn't yet appear to completely work, but here goes:You have to manually use the
R
key in less to get the display to update.It appears to work for
watchless date
but not forwatchless qstat
orwatchless pstree
, which both show blank. Any ideas?I don't see how this could be implemented as the row contents change, and
watch
would reset back to first line every 2 seconds even if you could scroll down.Some workarounds are:
watch 'qstat | tail -n40'
to show output of qstat beginning from 40th line from bottomwatch 'qstat | grep jsmith'
to grep the output so the lines you are interested in are always in the first screen.Note that you need to put the commands around the pipe in single quotes - otherwise you will be piping the output of
watch
, not the output ofqstat
.To continue on enkrs's answer,
watch 'qstat | head -300 | tail -15'
will get you arbitrary pages into the qstat's output.
Here's a rather crude script that seems to work for several commands that I threw at it
Used as such:
Being rather pedantic, the transition between refreshes aren't as smooth as I would like it to be. Naturally, being a simple script it doesn't support highlight of diff (watch -d). Also, the parsing of input arguments can be done better.
How about just: tail -f
I implement a simple python script to satisfy this request, named "watchall"
get it by: pip install watchall
replace watch with watchall and enjoy scrollable screen. now it only supports -n and -d flags.
I am using this: