[clug] BUFSIZ - how do you look it up?

Hal Ashburner hal at ashburner.info
Sun Jan 13 20:59:37 MST 2013


On 14 January 2013 14:35, Carlo Hamalainen <carlo.hamalainen at gmail.com>wrote:

> On Mon, Jan 14, 2013 at 1:28 PM, Hal Ashburner <hal at ashburner.info> wrote:
>
>> How are you guys doing it? via an internet search engine as a way of
>> indexing the content of the manpages? Is there something local that can
>> tell you:
>>
>> "Yay and this string "stdio.h" appears in the following man pages where it
>> lists them:
>> Or in this case give me (3) setbuf if that's really all there is.*
>>
>
> Does this do the trick?
>
> man -w -K stdio.h
>
> Seems a bit slow though.
>
>
I didn't see -K in my search of man man, thanks for pointing it out and how
it can be combined with -w.

But yes and in addition also has the same issue as my one liner in counting
symlinks. Which is easy enough to check for, so I did when I pasted it into
a script in my bin. Plus it man -K -w gave me false positives, eg getpwnam
when searching for BUFSIZ - I think due to lack of case sensitivity.

script below, in case anyone is remotely interested...

[hal at chimera 14:53 share/man/man3 ] manpage BUFSIZ 3
getpass
setbuf
stdio
strlcpy

vs

 [hal at chimera 14:53 share/man/man3 ] man -w -K BUFSIZ
/usr/share/man/man1/avconv.1.gz
/usr/share/man/man1/dig.1.gz
/usr/share/man/man1/enc.1ssl.gz
/usr/share/man/man1/ffmpeg.1.gz
/usr/share/man/man1/mplayer.1.gz
/usr/share/man/man1/mplayer.1.gz
/usr/share/man/man1/wodim.1.gz
/usr/share/man/man1/rstartd.1.gz
/usr/share/man/man1/wodim.1.gz
/usr/share/man/man1/xterm.1.gz
/usr/share/man/man1/zshbuiltins.1.gz
/usr/share/man/man1/zshmodules.1.gz
/usr/share/man/man8/mount.cifs.8.gz
/usr/share/man/man8/mount.cifs.8.gz
/usr/share/man/man8/mount.cifs.8.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/getlogin.3.gz
/usr/share/man/man3/getlogin.3.gz
/usr/share/man/man3/getlogin.3.gz
/usr/share/man/man3/getpass.3.gz
/usr/share/man/man3/getpwnam.3.gz
/usr/share/man/man3/getpwnam.3.gz
/usr/share/man/man3/getpwnam.3.gz
/usr/share/man/man3/getpwnam.3.gz
/usr/share/man/man3/profil.3.gz
/usr/share/man/man3/readpassphrase.3.gz
/usr/share/man/man3/setbuf.3.gz
/usr/share/man/man3/setbuf.3.gz
/usr/share/man/man3/setbuf.3.gz
/usr/share/man/man3/setbuf.3.gz
/usr/share/man/man3/stdio.3.gz
/usr/share/man/man3/stdio_ext.3.gz
/usr/share/man/man3/strlcpy.3.gz
/usr/share/man/man2/ioctl_list.2.gz
/usr/share/man/man2/readlink.2.gz
/usr/share/man/man2/readlinkat.2.gz
/usr/share/man/man5/ldap.conf.5.gz
/usr/share/man/man5/services.5.gz



#!/bin/bash
# isn't this better than a one liner? ;-)

SEARCHSTRING=${1:-""}
SECTION=${2:-""}

usage()
{
        echo "usage: $0 \"search string\" [section]"
        echo "eg: $0 \"BUFSIZ\" 3"
        exit 1
}

if  [[ ! $SECTION ]]
then
        echo default to section 1
        SECTION=1
fi

if  [[ ! $SEARCHSTRING ]]
then
        echo bad searchstring: ${SEARCHSTRING}
        usage
fi

for page in /usr/share/man/man3/*
do
        if [[ -L $page ]]
        then
                continue
        fi
        zcat $page | grep -rn BUFSIZ > /dev/null
        if [[ $? == 0 ]]
        then
                page=${page##/*/}
                echo ${page%%.*}
        fi
done


More information about the linux mailing list