Hi Ralph,
On 7/23/22 12:36, Ralph Corderoy wrote:
Hi Alejandro,
Wandering off-topic...
$ find man* -type f \
| tr '[:upper:]' '[:lower:]' \
| sort \
| uniq -d \
| while read f; do
find man* -type f \
| grep -i $f;
done;
man2/_Exit.2
man2/_exit.2
man3/nan.3
man3/NAN.3
You may like to know GNU's uniq(1) has ‘-D’ to print all duplicates
and ‘-i’ to ignore case.
$ find -type f | sort -f | uniq -Di
./man2/_exit.2
./man2/_Exit.2
./man3/nan.3
./man3/NAN.3
./man3/sd_bus_error_map.3
./man3/SD_BUS_ERROR_MAP.3
./man8/pam.8
./man8/PAM.8
$
Hmm, interesting options.
$ find man* -type f \
| tr '[:upper:]' '[:lower:]' \
| sort \
| uniq -d \
| while read f; do
find man* -type f \
| grep -i $f;
done \
| while read f; do
echo ===$f===;
head -n1 $f;
done;
GNU's grep(1) has ‘-m’ for the maximum number of matches.
Interesting use of grep(1) to combine printf(1) and head(1) too.
$ grep -m1 ^ `find -type f | sort -f | uniq -Di`
I'm a big fan of pipes and xargs(1). I only use `` or $() when I
_really_ need to. I'd use:
$ find -type f | sort -f | uniq -Di | xargs grep -m1 ^
This more clearly shows the processing done step by step.
It also has the benefit of not being limited to ARG_MAX.
./man2/_exit.2:.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
./man2/_Exit.2:.so man2/_exit.2
./man3/nan.3:.\" Copyright 2002 Walter Harms
([email protected])
./man3/NAN.3:.so man3/INFINITY.3
./man3/sd_bus_error_map.3:.so sd_bus_error_add_map.3
./man3/SD_BUS_ERROR_MAP.3:.so sd_bus_error_add_map.3
./man8/pam.8:.so PAM.8
./man8/PAM.8:'\" t
$
Cheers,
Alex
--
Alejandro Colomar
Linux man-pages comaintainer; http://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/