Ake Koomsin

Seeing All Man Pages Available in a Section on FreeBSD

When I am working with a kernel module in FreeBSD, there are times that I want to see all functions available in man 9. I know that apropos is out there but I sometimes don’t know the keyword.

Because of this, I decided to write a simple zsh script to list all available pages in a section, not only in section 9.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function ls_man() {
    if [[ $# -ne 1 ]]; then
        echo "Number of argument must be 1" >&2
        echo "Usage: ls_man [1-9]" >&2
        return 1
    fi

    if [[ $1 == [1-9] ]]; then
        ls /usr/share/man/man$1 | awk '{ split($1, name, ".") } { print name[1] }'
        return 0
    else
        echo "Wrong argument" >&2
        echo "Usage: ls_man [1-9]" >&2
        return 1
    fi
}