[clug] comparing the output of two saved 'ps' listings... 'watch' on saved files vs live cmd - possilbe?

Francis Whittle fj.whittle at gmail.com
Sat Dec 19 02:13:49 UTC 2015

After a little experimenting, I came up with a wdiff command:

wdiff -1 -y `tput rev` -z `tput sgr0` -d <(diff -u ps1 ps2)

-1 suppresses deletions, so you will only see the *new* pieces (I think
this is how watch -d works)
The tput commands are for turning reverse video on and off for insertions.
"-d <(diff -u ps1 ps2)" is using the output of a unified diff to suppress
contextually irrelevant lines that have not changed.  You could just put
the file names as arguments there to show the full list with changes

- Francis

On Fri, 18 Dec 2015 at 20:56 steve jenkin <sjenkin at canb.auug.org.au> wrote:

> I’d like to be able to see , in the style of ‘watch’s visual highlighting,
> the difference between pairs of files, which are captures of the ‘ps -ef’
> (or 'ps aux' for the BSD ppl).
> I’m primarily looking for a command-line / TTY tool, not an X-11/GUI tool.
> ‘sdiff’ doesn’t quite do it for me … truncates the lines on the left side.
> Using the context option of diff (-c) makes things things worse for these
> files.
> In Ubuntu, there’s a package ‘vbindiff’ that may do what I want, but it’s
> labelled ‘visual binary diff’.
> There’s also something called ‘kdiff3’ that I haven’t checked out. [I run
> KDE, can use it.]
> Haven’t tried vimdiff - was put off by it not being a PAGER but editor.
> If I can see even parts of the files, I can do something later with the
> captured ‘ps’ files to break them into pieces so, then compare
> corresponding pieces, if I can
> I can get close to what I want with ‘watch’ [‘-g’ - exit on a change. ‘-d’
> - highlight diffs]
> Window 1.
> > watch -d -n 5 -g head -30 ps.txt
> Window 2.
> > cp new-ps ps.txt
> Thanks in Advance
> steve
> --
> Steve Jenkin, IT Systems and Design
> 0412 786 915 (+61 412 786 915)
> PO Box 48, Kippax ACT 2615, AUSTRALIA
> mailto:sjenkin at canb.auug.org.au http://members.tip.net.au/~sjenkin
> --
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux

More information about the linux mailing list