Man pages, once changed to a human-readable form, are text files that you can diff with whatever tool that suits you. Here are two examples, as two bash
functions, for two tools: diff
and vimdiff
. Adapt them to your favorite tool.
With vimdiff
:
vimdiff_man() { vimdiff -R <(man --manpath="/old/path/to/man" "$1") <(man "$1"); }
With diff
, side by side, adjusted to your screen width:
diff_man() (
width="${COLUMNS:-80}"
export MANWIDTH=$((width / 2 - 2))
diff -y -W"$width" <(man --manpath="/old/path/to/man" "$1") <(man "$1") | less
)
In each function, I'm diffing between two pseudo files <(...)
, each of which containing the result of the man
command between parentheses (this is bash's Process Substitution).
/old/path/to/man
is the directory hierarchy containing your old manual pages. It is expected to have the same secondary man levels man1
, man2
, ... as your main manual directory (probably /usr/share/man
). Change it to fit your needs.
Usage:
diff_man sshd_config
vimdiff_man sshd_config
grep
is only meant to (and was only initially) print(ing) the lines matching a pattern. That's what grep
means (based on the g/re/p
ed
command).
Now, some grep
implementations have added a few features that encroaches a bit on the role of other commands. For instance, some have some -r
/--include
/--exclude
to perform part of find
's job.
GNU grep
added a -o
option that makes it perform parts of sed
's job as it makes it edit the lines being matched.
pcregrep
extended it with -o1
, -o2
... to print what was matched by capture groups. So with that implementation, even though it was not designed for that, you can actually replace:
sed 's/old/new/'
with:
pcregrep --om-separator=new -o1 -o2 '(.*?)old(.*)'
That doesn't work properly however if the capture groups match the empty string. On an input like:
XoldY
Xold
oldY
it gives:
XnewY
X
Y
You could work around that using even nastier tricks like:
PCREGREP_COLOR= pcregrep --color=always '.*old.*' |
pcregrep --om-separator=new -o1 -o2 '^..(.+?)old(.+)..' |
pcregrep -o1 '.(.*).'
That is, prepend and append \e[m
(coloring escape sequence) to all matching lines to be sure there is at least one character on either side of old
, and strip them afterwards.
Best Answer
You could look at the Manual Page Library, it has some early UNIX manuals...