On 2025-05-29 15:08, Jason McIntyre wrote:
> On Wed, May 28, 2025 at 05:22:55PM -0300, K R wrote:
> > >Synopsis: fortune(6): fortunes2 file has duplicate entries
> > >Category: system games
> > >How-To-Repeat:
> > cd /tmp
> > cp /usr/share/games/fortune/{fortunes,fortunes2} .
> > split -a 4 -p '^%$' fortunes fortunes.
> > split -a 4 -p '^%$' fortunes2 fortunes2.
> > sha256 fortunes.* > SHA256.fortunes
> > sha256 fortunes2.* > SHA256.fortunes2
> > # compare the two SHA256 files...
>
> this methodology is too smart for me!
You should be able to get similar results with
$ cd /usr/share/games/fortune
$ awk 'BEGIN{RS="\n%\n"} {f=FILENAME ":#" FNR; if ($0 in a) {print f "="
a[$0];print} else a[$0]=f}' fortunes fortunes2 # ...
which just does an equality-check rather than checking cryptographic
hashes (and requiring disk-space for the temporary files). It emits
record-numbers rather than line-numbers, but if you use vim/neovim[1],
you should be able to do
1953/^%$
to land at record 1953.
-tkc
[1] TIL that the "/" operator in nvi(1) doesn't accept a count like I
would have expected
--