Следующий bash
скрипт рекурсивно находит все имена обычных файлов (или символические ссылки на обычные файлы ), которые дублируются в пути верхнего -уровня, указанном в командной строке скрипта (или в текущем каталоге, если путь не указан ).
В конце приводится сводка по каждому дублированному имени файла с:
-списком имен каталогов с разделителями, в которых может быть найдено это имя файла.
#!/bin/bash
shopt -s globstar # enable the ** glob
shopt -s dotglob # also let patterns match hidden files
declare -A dirs # where we store directories for each found name
for pathname in "${1:-.}"/**; do
[ ! -f "$pathname" ] && continue # not something we're interested in
name=${pathname##*/}
if [ -n "${dirs[$name]}" ]; then
# we have seen this filename before
dups+=( "$name" )
fi
# append directory name to ':'-delimited list for this filename
dirs[$name]=${dirs[$name]:+"${dirs[$name]}:"}"${pathname%/*}"
done
# go through the list of duplicates and
# print the found directory names for each
for name in "${dups[@]}"; do
printf '%s:\n\t%s\n' "$name" "${dirs[$name]}"
done
Пример запуска:
$ bash script.sh
somefile:
./a:./b
.profile:
.:./t
Сводка сообщает нам, что .profile
находится в текущем каталоге, а также в каталоге t
, и что somefile
находится в каталогах a
и b
.
Заголовок в rpc (3 )определяется макросом заголовка .Dt
:
$ zcat $(man -w 3 rpc) | head
.\" @(#)rpc.3n 1.31 93/08/31 SMI; from SVr4
.\" Copyright 1989 AT&T
.Dd May 7, 1993
.Dt RPC 3
.Os
.Sh NAME
.Nm rpc
.Nd library routines for remote procedure calls
.Sh SYNOPSIS
.In rpc/rpc.h
Вы можете прочитать об этом вman 7 groff_mdoc
:
TITLE MACROS
The title macros are part of the page structure domain but are presented
first and separately for someone who wishes to start writing a man page
yesterday. Three header macros designate the document title or manual
page title, the operating system, and the date of authorship. These
macros are called once at the very beginning of the document and are used
to construct headers and footers only.
.Dt [⟨document title⟩] [⟨section number⟩] [⟨volume⟩]
The document title is the subject of the man page and must be in
CAPITALS due to troff limitations. If omitted, ‘UNTITLED’ is
used. The section number may be a number in the range 1,..., 9
or ‘unass’, ‘draft’, or ‘paper’. If it is specified, and no vol‐
ume name is given, a default volume name is used.
Under BSD, the following sections are defined:
1 BSD General Commands Manual
2 BSD System Calls Manual
3 BSD Library Functions Manual
4 BSD Kernel Interfaces Manual
5 BSD File Formats Manual
6 BSD Games Manual
7 BSD Miscellaneous Information Manual
8 BSD System Manager's Manual
9 BSD Kernel Developer's Manual
Например, если вы измените его на .Dt RPC 9
, вы получите:
RPC(9) BSD Kernel Developer's Manual RPC(9)