Home > News Tips

How to Export Terminal Man Page as a Text/PDF File on Mac?

Updated on Friday, June 14, 2024

iBoysoft author Jenny Zeng

Written by

Jenny Zeng
Professional tech editor

Approved by

Jessica Shee

English Français Deutsch やまと Español Português

macOS Terminal man page

The macOS Terminal app doesn't provide a great experience for reading man (manual) pages. If you're tired of viewing a man page in Terminal or you want to document a man page for future retrieval, you can use the methods laid out in this post.

How to export a man page in Terminal as a plain text file?

There are two ways to export a Terminal man page as a plain text file.

Use the Shell menu: Inside Terminal, click Shell at the menu bar, then select "Export Text As" and choose a desired location to export all texts of a man page from Terminal. If you only want to export selective texts, select them, then click Shell > Export Selected Text As. (This is also helpful for saving commands output in Terminal.)

How to export macOS Terminal man page as a text file using the Shell menu

Run Terminal command: You can also execute a Terminal command to export the man page of a command as a text file.

man command | col -bx > /path/to/command.txt

For instance, if you want to export the ls man page to a new plain text file on your desktop and name it as ls.txt, the command should be: man ls | col -bx > ~/desktop/ls.txt

How to export macOS Terminal man page as a text file by running command

Spread the information by sharing this post!


How to convert a Terminal man page as a PDF?

If you want to convert a Terminal man page into a PDF file on Mac, you can try the following methods:

① Use the pstopdf command

man -t command | pstopdf -i -o name.pdf

Replace "command" and "name" with the ones you want to use. For example, to convert the ls man page into a PDF and name it ls.pdf, run: man -t ls | pstopdf -i -o ls.pdf. If the command executes successfully, you'll find the ls.pdf file in your home directory (e.g., Macintosh HD/Users/Jenny).

② Convert from .txt to .pdf

You can first save the man page as a text file, as we mentioned in the first section of this post. Then open the text file with TextEdit and click File > Export as PDF to convert it into a PDF file.

How to convert a Terminal man page into PDF

③ Copy the content of the man page and paste it to a PDF file

As an alternative, you can copy all texts on a man page to the clipboard and then paste them into a PDF file.

Press Command + C to copy the texts, or execute the command below:

man command | col -b | pbcopy

For example, to copy the contents of the ls man page, run: man ls | col -b | pbcopy

Share this post to help others convert Terminal man pages to PDFs!