#!/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/$secti.$mpage.pdf
done <apropos.txt
pdftk 0.pdf 1.pdf pages/1*pdf 2.pdf pages/2*pdf 3.pdf pages/3*pdf 4.pdf pages/4*pdf 5.pdf pages/5*pdf 6.pdf pages/6*pdf 7.pdf pages/7*pdf 8.pdf pages/8*pdf cat output man.pdf