KandZ – Tuts

We like to help…!

Linux CLI 50 🐧 groff command

a - groff command introduction
groff command is used to create simple text documents and troff (TeX) formats
It uses macros similar to those used by UNIX typesetters
It is mainly used to create man(manual) pages
commons options: -T[dev] → directs the input to output device dev
-i → reads the standard input after all the named input files have been processed
-m[dir] → searches dir for macro files -n[num] → the first page num
some available devices: ps → PostScript pdf → PDF ascii → ASCII character set utf8 → UTF-8 encoding html → HTML
grof file → start writing and export to file to write the text and Ctrl + D to save it

b - some groff embedded commands
.sp → spaces one line .sp 5 → speces 5 lines .sp 2.5c → leaves 2.5 cm
.ce 100 → centers 100 lines .ce 0 → stops centering
.bt → line break .bp → page break
.in → indent line .in 4 → indent 4 lines .ti → temporary indent
.po 10 → page offset 10 characters .ps 20→ font size 20
.ss 12 → space-character size .ad → line adjustment l|r|c|b|n .na → no adjustment
more details at https://www.troff.org/54.pdf

c - groff examples
groff -Thtml → formats the text you write in HTML
groff -Thtml index.html → formats the text and saves it to HTML file
echo hello, Linux! hello.tr → creates hello.tr with hello, Linux content
groff hello.ts → displays the hello.tr file
groff -Tpdf hello.tr output.pdf → creates a pdf file from hello.tr
man -P cat cat | groff -Thtml cat.html → creates an HTML from the cat manual

Leave a Reply