col - Remove reverse line feeds

Format

col [-bfpx] [file ...]

The col utility is fully supported for compatibility with older UNIX systems. However, because it is no longer supported by POSIX.2 IEEE standard 1003.2-1992, do not use this utility for applications intended to be portable to other UNIX-branded systems.

Description

col processes control characters for vertical line feeds and writes the processed text to the standard output. If you do not specify any files, colreads from the standard input. Otherwise, col will read and process each specified file in sequence. It is intended to be used as a filter between a program such as nroff and an output device that cannot handle reverse line feeds.

Where possible, blank characters (spaces) are converted to tabs; tab stops are assumed to be every eight characters.

col also removes all escape sequences except for those shown in the following table. ESC is the ASCII escape character, octal code 033.
Character ASCII control character
Backspace 010
Carriage-return 015
Newline 012
Vertical tab 013
SO 016
SI 017
Space 040
Tab 011
Reverse line feed ESC-7
Reverse half-line feed ESC-8
Forward half-line feed ESC-9

The ASCII control characters SO and SI denote the beginning and end of text in an alternative character set. The set of each input character is remembered. col generates SO and SI characters as needed to output each character in the correct character set.

Options

-b
Ignores backspace (CRTL-H) characters. If two characters are supposed to appear in the same space, the first character is ignored and the second is output.
-f
Allows forward half-line motions. Typically, these are changed to forward full-line motions.
-x
Prevents conversion of spaces to tab characters.

Localization

col uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

Usage notes

  1. Because col ignores vertical motions that back up over the first line, you might get unexpected results if the first line contains superscripts.
  2. Because -f allows escape sequences, it might cause unexpected results on terminals.

Exit values

0
Successful completion
1
Failure due to any of the following reasons:
  • Incorrect command-line option.
  • Insufficient memory.

Portability

UNIX systems.

This implementation does not handle double-byte characters.