#!/bin/bash
rm apropos.txt
rm mpages.txt
for i in {1..8}; do
echo $i
(apropos -s $i .)>>apropos.txt
done
while read p; do
rline=$p
mpage=$(echo $rline | cut -d ' ' -f1)
secti=$(echo $rline | cut -d ' ' -f2 | tr -d '()')
echo $secti $mpage
man -t $secti $mpage | ps2pdf - pages/$mpage.pdf
done <apropos.txt
pdftk pages/* cat output man.pdf