acut

trcol (1)     Delete or Translate columns of a file     (Apr 2005)


Syntax
trcol [–acols ] [–Acols ] [–bcols ] [–Bcols ] [–dcols ] [–lcols ] [–rcols ] [–scols ] [–tcols s1 s2] [file...]

Description
The trcol command allows to delete or translate specified columns from a file. A test for blanks (spaces or tabs) may be performed (–b option).

The cols selection has the form start[end[,...]], start and end being the starting and ending column of a field. For instance, colums 1, 3 to 5, and beyond 80 (81 or more) are written 1,3-5,81-. The complete line is written 1-

Note that trcol cannot exchange columns nor insert text; see acut(1) for such facilities.

Options

The options allow to specify whether we wish to delete or translate columns.

–acols    asks to transform to lowercase the specified columns.

–Acols    asks to transform to uppercase the specified columns.

–bcols    asks to delete with blank test the specified columns. Non-blank columns are deleted, but a warning message is issued for each non-blank character which was removed. The returned status is the number of non-blank deleted characters.

–Bcols    is similar to the -b option, but no warning message is issued; just the number of deleted non-blank characters is returned as a status.

–dcols    asks to delete the specified columns without any test.

–lcols    asks to left-justify the specified columns – blanks existing at the left are moved to the right.

–rcols    asks to right-justify the specified columns – blanks existing at the right are moved to the left.

–scols    asks to squeeze blanks in the specified columns: blanks existing at the left are mobed to the right, and multiple blanks are converted into a single blank.

–tcols    s1 s2 asks to translate in the columns defined by cols characters from s1 into the corresponding characters of s2 (byte-per-byte translation). Strings s1 and s2 must have the same length. The dash (-) may be used to specify intervals, e.g. a-z for the 26 lowercase letters. Non-printable characters can be specified using the C conventions.

file    is the name of one or several (concatenated) input files. stdin is the default input file.

Restrictions
Only one operation is performed for each column; when the column ranges specified by the various options overlap, the operation applied on the shortest column is applied.

Restrictions
Only one operation is performed for each column; when the column ranges specified by the various options overlap, the operation applied on the shortest column is applied.

Returned Status
The trcol command returns 0 for successful operation, 1 when one or more n,on-blank columns are deleted (in the –b or –B options), or 2 in case of error such as inexistant file.

Example
Remove from standard input columns 2 to 5 with error message for non-blank columns, change the blank of column 6 to a zero, and convert cols 73 and above to lower-case letters:

trcol -b2-5 -t6 ' ' '0' -t73- 'A-Z' 'a-z'

See also
acut(1)