3

I was trying to render the troff file https://github.com/bit-team/backintime/blob/master/common/man/C/backintime-config.1 in terminal.

How can I make the output (using cat or some other utility) look like the way man outputs troff file in the terminal?

Do I need to convert the troff file to some format understood by the terminal?


Note: I am not looking to export it to pdf or html

3
  • The question does not specify an operating system, and man built upon groff exists on at least (older) FreeBSD and Linux-based operating systems. Commented Jul 7, 2020 at 16:27
  • I'm really unfamiliar with the subject, but groffer --tty your_file is probably an easy way. (I see that groffer is provided by the groff package on Ubuntu, which is likely not installed by default). Commented Jul 7, 2020 at 18:14
  • Related unix.stackexchange.com/questions/313085/… Commented May 2, 2024 at 11:39

2 Answers 2

6

Just do

man "${Path-To-Troff-File}" 
2
  • It's not that simple. With some implementations of man this only works if the path contains a directory prefix. Commented Jul 7, 2020 at 16:25
  • man ./Troff-File-Name worked for me only with ./ prefix for a file from current directory. Commented May 1, 2024 at 21:27
2

Another option (depending on system): use the groff tool with the appropriate troff post processing macro for output to a TTY device, e.g. utf8.

# To stdout
$ groff -man -T utf8 file.1

# From archive via pipe
$ zcat file.1.gz | groff -man -T utf8 -i

# Pass to less
$ groff -man -T utf8 file.1 | less -R
...

One can use grog to detect what macro to use, and optionally execute by using --run and passing options to groff. For example:

$ grog file.1
groff -man file.1
$ grog --run -T utf8 file.1
groff -T utf8 -man file.1
[DOC]
...
  • groff - front-end for the groff document formatting system.
  • grog - guess options for a following groff command.

  • groff_tmac - macro files in the GNU roff typesetting system.
  • groff_man - compose manual pages with GNU roff.
  • grotty - groff driver for typewriter-like devices.
  • nroff – use groff to format documents for TTY devices.
  • troff - the troff processor of the groff text formatting system.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.