How to make a man page for my shell script? How to make a man page for my shell script? unix unix

How to make a man page for my shell script?


I'd recommend you to use Grapse, an online man page editor, since you can see the results in real-time. I believe it's really useful for beginners.


What about using pandoc. You can write document in markdown (or even html, latex) and can covert to html, pdf, word,man pages, epub, .... This way you can write documentation in one format and convert/distribute in any format you like


Sample man page, from the link:

.\" Manpage for nuseradd..\" Contact vivek@nixcraft.net.in to correct errors or typos..TH man 8 "06 May 2010" "1.0" "nuseradd man page".SH NAMEnuseradd \- create a new LDAP user.SH SYNOPSISnuseradd [USERNAME].SH DESCRIPTIONnuseradd is high level shell program for adding users to LDAP server.  On Debian, administrators should usually use nuseradd.debian(8) instead..SH OPTIONSThe nuseradd does not take any options. However, you can supply username..SH SEE ALSOuseradd(8), passwd(5), nuseradd.debian(8).SH BUGSNo known bugs..SH AUTHORVivek Gite (vivek@nixcraft.net.in)

Installing with your script:

install -g 0 -o 0 -m 0644 nuseradd.1 /usr/local/man/man8/gzip /usr/local/man/man8/nuseradd.1

Installing it manually:

cp nuseradd /usr/local/man/man8/nuseradd.1gzip /usr/local/man/man8/nuseradd.1