Linux vgrind command

Updated: 05/04/2019 by Computer Hope
vgrind command

On Unix-like operating systems, the vgrind command "grinds" program listings, creating a more appealing output format.


The vgrind utility formats the program sources named by the filename arguments in a nice style using troff. Comments are placed in italics, keywords in bold face, and as each function is encountered its name is listed on the page margin.

vgrind runs in two basic modes, filter mode or regular mode. In filter mode, vgrind acts as a filter in a manner similar to tbl. The standard input is passed directly to the standard output except for lines bracketed by the troff-like macros:

.vS starts processing
.vE ends processing

These lines are formatted as described above. The output from this filter can be passed to troff for output. There need be no particular ordering with eqn or tbl. In regular mode, vgrind accepts input file names, processes them, and passes them to troff for output. Use a hyphen ('-') to specify standard input; otherwise, vgrind will exit without attempting to read from the standard input. File names must be specified after all other option arguments.

In regular mode, if the -t or -P option is specified, the output is:

  • emitted (in troff format) to stdout if the -t option is specified.
  • printed (as PostScript) to the named printer if the -P option is specified.

Otherwise, the output is:

  • printed (as PostScript) on the system default printer, if one is defined, and the command's stdout is a tty.
  • emitted (as PostScript) to stdout if it is not a tty (that is, if stdout is a pipe or a redirect to a file).

In both modes, vgrind passes any lines beginning with a decimal point without conversion.


vgrind [-2] [-f] [-n] [-t] [-w] [-W] [-x] [-d defs-file] [ -h header] 
       [-l language] [-s n] [-o pagelist] [ -P printer] [-T output-device] 


-2 Produces two-column output. Specifying this option changes the default point size to 8 (as if the -s8 option were supplied). It also arranges for output to appear in landscape mode, by supplying the -L flag to the formatter and changing the page height and width accordingly.
-f Forces filter mode.
-n Does not make keywords boldface.
-t Similar to the same option in troff; that is, formatted text goes to the standard output.
-w Considers TAB characters to be spaced four columns apart instead of the usual eight.
-W Forces output to the (wide) Versatec printer rather than the (narrow) Varian.
-x Outputs the index file in a "pretty" format. The index file itself is produced whenever vgrind is run with a file called index present in the current directory. The index of function definitions can then be run off by giving vgrind the -x option and the file index as argument.
-d defs-file Specify an alternate language definitions file (default is /usr/lib/vgrindefs).
-h header Specify a header to appear in the center of every output page.
-l language Specify the language to use. Among the languages currently known are: Bourne shell (-lsh), C (-lc, the default), C++ (-lc++), C shell (-lcsh), emacs MLisp (-lml), FORTRAN (-lf), Icon (-lI), ISP (-i), LDL (-lLDL), Model (-lm), Pascal (-lp), and RATFOR (-lr).
-s n Specify a point size to use on output (exactly the same as the argument of a troff .ps point size request).
-o pagelist Prints only those pages whose page numbers appear in the comma-separated pagelist of numbers and ranges. A range N-M means pages N through M; an initial -N means from the beginning to page N; and a final N- means from N to the end.
-P printer Sends output to the named printer.
-T output-device Formats output for the specified output-device.
filename Name of the program source to be processed by vgrind. Use '-' to specify the standard input.


vgrind -t myfile.c | lpr -t

print a formatted listing of the program file myfile.c.

csh — The C shell command interpreter.
ctags — Create tag files for source code.
eqn — Language processor for describing equations.
tbl — Preprocessor which formats tables for nroff or troff.
troff — Typeset or format documents for terminal display or line-printer.