Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Google   


col - A semi-forgotten tool to converting man pages to text

The col utility reads from the standard input and writes to the standard output. It performs the line overlays implied by reverse line-feeds, and by forward and reverse half- line-feeds. It accepts several options

col [ -bfpx ]

Unless  option -x is used, all blank characters in the input will be converted to tab characters wherever possible. col is useful for filtering multi-column output made with the .rt command of nroff(1) and output resulting from use of the tbl(1) preprocessor but who uses those nowadays ?

The classic usage of col became converting man pages to text files:

 man wgateway | col -bx | mailx myself@mydomain

The ASCII control characters SO and SI are assumed by col to start and end text in an alternative character set. The character set to which each input character belongs is remembered, and on output SI and SO characters are generated as appropriate to ensure that each character is written in the correct character set.

On input, the only control characters accepted are space, backspace, tab, carriage-return and newline characters, SI, SO, VT, reverse line-feed, forward half-line-feed and reverse half-line-feed. The VT character is an alternative form of full reverse line-feed, included for compatibility with some earlier programs of this type. The only other characters to be copied to the output are those that are printable.

The ASCII codes for the control functions and line-motion sequences mentioned above are as given in the table below. ESC stands for the ASCII escape character, with the octal code 033; ESC- means a sequence of two characters, ESC followed by the character x.

     reverse line-feed             ESC-7
     reverse half-line-feed        ESC-8
     forward half-line-feed        ESC-9
     vertical-tab (VT)             013
     start-of-text (SO)            016
     end-of-text (SI)              017

OPTIONS

ENVIRONMENT VARIABLES

See environ(5) for descriptions of the following environment variables that affect the execution of col: LC_CTYPE, LC_MESSAGES, and NLSPATH.

EXIT STATUS

The following error values are returned:
     0     Successful completion.

     >0    An error occurred.

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:
     ____________________________________________________________
    |       ATTRIBUTE TYPE        |       ATTRIBUTE VALUE       |
    |_____________________________|_____________________________|
    | Availability                | SUNWesu                     |
    |_____________________________|_____________________________|
    | CSI                         | enabled                     |
    |_____________________________|_____________________________|

Example

#!/bin/ksh
#
# Solaris Man Page Save Script
# Purpose: Save man pages to ascii files
# Usage: Set variables and execute
# Dependencies: Data file containing command names
# (Solaris 8 commands included below)
# Outputs: Files named by the commands
#
## Submitter Email: gideon@infostruct.net
#*******************************************************

PATH=/usr/bin:/usr/sbin:/usr/ucb:/bin
MANPATH=/usr/share/man:/opt/SUNWvxvm/man:/opt/SUNWvxva/man

OUTPUTDIR=./manpgs

while read -r CMND
do

man $CMND | col -bx > $OUTPUTDIR/$CMND.txt

done < ./manpages.dat

exit 0


##############################################################################
### This script is submitted to BigAdmin by a user of the BigAdmin community.
### Sun Microsystems, Inc. is not responsible for the
### contents or the code enclosed. 
###
###
### Copyright 2007 Sun Microsystems, Inc. ALL RIGHTS RESERVED
### Use of this software is authorized pursuant to the
### terms of the license found at
### http://www.sun.com/bigadmin/common/berkeley_license.html
##############################################################################


NOTES

The input format accepted by col matches the output produced by nroff with either the -T37 or -Tlp options. Use -T37 (and the -f option of col) if the ultimate disposition of the output of col will be a device that can interpret half-line motions, and -Tlp otherwise.

col cannot back up more than 128 lines or handle more than 800 characters per line.

Local vertical motions that would result in backing up over the first line of the document are ignored. As a result, the first line must not have any superscripts.


Copyright © 1996-2008 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: February 28, 2008