📄 ch50_11.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 50] 50.11 Writing a Simple Man Page with the -man Macros </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:57:03Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch50_01.htm"TITLE="50. Help--Online Documentation, etc."><LINKREL="prev"HREF="ch50_10.htm"TITLE="50.10 Make Your Own Man Pages Without Learning troff"><LINKREL="next"HREF="ch50_12.htm"TITLE="50.12 Common UNIX Error Messages "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch50_10.htm"TITLE="50.10 Make Your Own Man Pages Without Learning troff"><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 50.10 Make Your Own Man Pages Without Learning troff"BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 50<BR>Help--Online Documentation, etc.</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch50_12.htm"TITLE="50.12 Common UNIX Error Messages "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 50.12 Common UNIX Error Messages "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-7570">50.11 Writing a Simple Man Page with the -man Macros </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-7570-IX-COMMANDS-WRITING-MANUAL-PAGES-FOR"></A><ACLASS="indexterm"NAME="UPT-ART-7570-IX-MANUAL-PAGES-WRITING"></A><ACLASS="indexterm"NAME="UPT-ART-7570-IX-MAN-MACROS"></A>If you're not satisfied with the simple manual pages we discussed in article <ACLASS="xref"HREF="ch50_10.htm"TITLE="Make Your Own Man Pages Without Learning troff">50.10</A>,here's how to go all the way and create a "real" manual page.As we said, the best way to create a manual page is to copy one thatalready exists.So here's a sample for you to copy.Rather thandiscuss it blow by blow, I'll include lots of comments (these start with<CODECLASS="literal">.\"</CODE> or <CODECLASS="literal">\"</CODE>).</P><PCLASS="para"><TABLECLASS="screen.co"BORDER="1"><TR><THVALIGN="TOP"><PRECLASS="calloutlist"> <ACLASS="co"HREF="ch50_01.htm"TITLE="50.1 UNIX Online Documentation ">1</A> <ACLASS="co"HREF="ch50_02.htm"TITLE="50.2 The apropos Command ">apropos</A> </PRE></TH><TDVALIGN="TOP"><PRECLASS="screen">.\" Title: Program name, manual section, and date.TH GRIND 1 .\" Section heading: NAME, followed by command name and one line summary.\" It's important to copy this exactly; the "whatis" database (used.\"for apropos) looks for the summary line..SH NAME .\"grind \- create output from input.\" Section heading: SYNOPSIS, followed by syntax summary.SH SYNOPSIS .B grind \" .B: bold font; use it for the command name.[ -b ] [ -c ] [ -d ] \" Put optional arguments in square brackets.[ input [ output ]] \" Arguments can be spread across several lines..br \" End the synopsis with an explicit line break (.br).\" A new section: DESCRIPTION, followed by what the command does.SH DESCRIPTION.I Grind \" .I: Italic font for the word "Grind"performs lots of computations. Input to .IR grind , \" .IR: One word italic, next word roman, no space between.is taken from the file.IR input ,and output is sent to the file.IR output ,which default to standard input and standard output if not specified..\" Another section: now we're going to discuss the -b, -c, and -d options.SH OPTIONS.\" The .TP macro precedes each option .TP .B \-b \" print the -b option in bold. Print output in binary..TP.B \-c \" \- requests a minus sign, which is preferable to a hyphen (-) Eliminate ASCII characters from input before processing..TP.B \-d Cause daemons to overrun your computer..\" OK, we're done with the description and the options; now mention.\" other requirements (like environment and files needed) as well as.\" what can go wrong. You can add any other sections you want..SH FILES.PD 0.TP 20.B /dev/nulldata file.TP.B /tmp/grind*temporary file (typically 100 Megabytes).PD.SH BUGSIn order to optimize computational speed, this program always producesthe same result, independent of the input..\" Use .LP between paragraphs.LPIf the moon is full, .I grindmay destroy your input file. To say nothing of your sex life..\" Good manual pages end by stating who wrote the program..SH AUTHORI wouldn't admit to this hack if my life depended on it.</PRE></TD></TR></TABLE></P><PCLASS="para">After all that, you should have noticed that there are four importantmacros, listed in <ACLASS="xref"HREF="ch50_11.htm#UPT-ART-7570-TAB-0"TITLE="Important -man Macros">Table 50.2</A>, to know about.</P><TABLECLASS="table"><CAPTIONCLASS="table"><ACLASS="title"NAME="UPT-ART-7570-TAB-0">Table 50.2: Important -man Macros</A></CAPTION><THEADCLASS="thead"><TRCLASS="row"VALIGN="TOP"><THCLASS="entry"ALIGN="LEFT"ROWSPAN="1"COLSPAN="1">Macro</TH><THCLASS="entry"ALIGN="LEFT"ROWSPAN="1"COLSPAN="1">Meaning</TH></TR></THEAD><TBODYCLASS="tbody"><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">.TH</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Title of the manual page.</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">.SH</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Section heading; one for each section.</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">.TP</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Formats options correctly (sets up the "hanging indent").</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">.LP</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Used between paragraphs in a section.</TD></TR></TBODY></TABLE><PCLASS="para">For some arcane reason, all manual pages use the silly <CODECLASS="literal">.B</CODE>,<CODECLASS="literal">.BI</CODE>, etc., macros to make font changes.I've adhered to thisstyle in the example, but it's much easier to use "in line" fontchanges: <CODECLASS="literal">\fI</CODE> for <EMCLASS="emphasis">italic</EM>, <CODECLASS="literal">\fB</CODE> for <BCLASS="emphasis.bold">bold</B>,and <CODECLASS="literal">\fR</CODE>for roman.There may be some systems on which this doesn't work properly, but I'venever seen any.<ACLASS="indexterm"NAME="AUTOID-59691"></A><ACLASS="indexterm"NAME="AUTOID-59692"></A><ACLASS="indexterm"NAME="AUTOID-59693"></A></P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">ML</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch50_10.htm"TITLE="50.10 Make Your Own Man Pages Without Learning troff"><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 50.10 Make Your Own Man Pages Without Learning troff"BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch50_12.htm"TITLE="50.12 Common UNIX Error Messages "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 50.12 Common UNIX Error Messages "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">50.10 Make Your Own Man Pages Without Learning troff</TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">50.12 Common UNIX Error Messages </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed & awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -