I just started learning bash scripting and I've been trying to create a script that'd print every man page to a pdf file. Problem is I don't know how to handle errors for 'no manual entry found' and the script just creates a blank file for commands that have no manual entry.
#! /bin/bash
declare -a commands
commands=(pwd cd ls mkdir rmdir echo)
for i in "${commands[@]}"
do
man $i | pandoc --pdf-engine=pdfroff -o $i.pdf
done
Thanks in advance and I am sorry if it was a stupid question.