Is there a paging version of `watch`?
Solution 1
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:
C-a :height -w 300
C-a :width -w 100
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.
Solution 2
You can try this:
$ while vmstat; do sleep 1; done | less
replace vmstat
with qstat
and adjust the sleep
to your needs.
Solution 3
Multitail: http://www.vanheusden.com/multitail/
Example:
vmstat 1 |multitail -j
Scroll back by press 'b' and page/arrow up/down.
Solution 4
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:
#!/bin/bash -u
out=$(mktemp)
(while [ 1 ]; do
"$@" > $out;
sleep 2;
done) &
less $out
kill $!
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 for watchless qstat
or watchless pstree
, which both show blank. Any ideas?
Related videos on Youtube
David Dean
Updated on September 17, 2022Comments
-
David Dean almost 2 years
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
whatless
is tocat
.As an example, lets say I wanted to watch the output of
qstat
, I could usewatch 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 bywatch
. Is there any way to do this at the moment with existing utilities? -
David Dean almost 15 yearsall this does is keep repeating the command into
less
, which means that you need to keep scrolling to see the latest output. -
Spacen Jasset almost 15 yearsYes, but you can scroll back. You can't have both at once. Pressing shift f, that is capital 'F' will work like tail.
-
David Dean almost 15 yearsthe only issue then is how to continually repeat the command, while blanking the screen between each go
-
Steve Townsend almost 15 yearsOops, I meant run the watch command inside screen. Fixed.
-
warren almost 15 yearsyartls - yet another reason to love screen :)
-
henry about 6 yearsnote that
C-
is akactrl-
-
rymo over 4 yearsAppend
+F
to "pre-press" F and automatically follow:while vmstat; do sleep 1; done | less +F