NAME

recol - Reorder the columns of a file

SYNOPSIS

recol [-bcd] [-tx] { Cnn Snn Tnn Pnn m.n:j[(func)] }

-b Ignore leading blanks.

-c Use card image mode.

-tx Use x as the field delimiter (default is white space).

-Pxxxx Pass any lines that begin with xxxx through unchanged. This can be used as a handy way to preserve headings.

-d Set debugging messages.

Cnn move to output column n.

S[n] insert n Spaces at current position (default 1).

T[n] insert n Tabs.

B[n] insert n vertical Bars (|).

Pxxx Print xxx.

m.n:j[(function)] NormalMode: pick up logical column m, offset n, for length j and insert into output. Cardmode: pick up physical column m for length j (n is ignored). An optional function may be applied to the selected input data. The functions are.

toupper Convert the value to upper case.

tolower Convert the value to lower case.

~ Transpose the case of the value.

base(n) Convert the (integer) value of the field to base n (n <= 82);

len Emit the length of the value.

m+[(function)] as above, but pick up data from the designated column through the end of the input line. recol is a filter that reformats an input stream as specified by a script on the command line. It is meant as an easier to use alternative to awk and perl for many common reformatting jobs. (Actually, I originally wrote it for MS-DOS in 1982 because awk and sed were not available on that platform.) It can treat input as card images or separator delimited fields. The overall process is to read a line into a work buffer, apply the operations specified on the command line to build a new line image, then print the new image.

EXAMPLES

$ echo abc def ghi jkl mno pqr stu | ./recol  5 s2 3.1:1 b3 '1(toupper)'
pqr  k|||DEF
$ echo 0 1 2 35 4 5 6 7 72 9 | ./recol '8(base(36))' s '3(base(36))'
20 z
$ echo Abc def ghi jkl mno pqr stu | ./recol  3.1:7 b '0(~)'
kl|aBC
$ echo Abc def ghi jkl mno pqr stu | ./recol  2 b 1 b 3+
ghi|def|jkl mno pqr stu
$ echo abcedfghijklmnopqrstuvwxyz | ./recol -c 22+
wxyz
% echo hello tony | ./recol 0+ b '0+(len)' b '0(len)'
hello tony|10|5

BUGS

Column numbering starts with 0 rather than 1, but that's only a bug if you aren't a (real) programmer.

SEE ALSO

cut(1)

AUTHOR

Tony Aiuto <tony.aiuto@gmail.com>

GET THE SOURCE

http://www.aiu.to/sa/recol-2.0.0.tar.Z