Skip to content

Instantly share code, notes, and snippets.

@andrew-stclair
Last active July 5, 2024 02:20
Show Gist options
  • Select an option

  • Save andrew-stclair/49d96c6dfc4109ed1e1f479c1bb2b308 to your computer and use it in GitHub Desktop.

Select an option

Save andrew-stclair/49d96c6dfc4109ed1e1f479c1bb2b308 to your computer and use it in GitHub Desktop.
Export the Linux Manual to /opt/man in pdf format
#!/bin/bash
echo "Installing required software"
apt-get update
apt-get install groff man manpages manpages-dev -y
echo "Creating output directory if it does not exist"
SEARCH_DIR="/usr/share/man/"
OUT_DIR="/opt/man"
mkdir -p $OUT_DIR
echo "Exporting man pages"
for i in `find ${SEARCH_DIR} -name '*.gz'`; do
NEW_DIR=`dirname $i | sed "s|${SEARCH_DIR}||g"`
NAME=`basename $i | sed 's|.gz$|.pdf|g'`
mkdir -p ${OUT_DIR}/${NEW_DIR}
echo "${i} -> ${OUT_DIR}/${NEW_DIR}/${NAME}"
zcat $i | groff -mandoc -Tpdf > ${OUT_DIR}/${NEW_DIR}/${NAME}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment