delam.icn: Program to delaminate file

June 10, 1988; Thomas R. Hicks
This file is in the public domain.
   This program delaminates standard input into several output
files according to the specified fields.  It writes the fields in
each line to the corresponding output files as individual lines.
If no data occurs in the specified position for a given input
line an empty output line is written. This insures that all out-
put files contain the same number of lines as the input file.

   If - is used for the input file, the standard input is read.
If - is used as an output file name, the corresponding field is
written to the standard output.

   The fields are defined by a list of field specifications,
separated by commas or colons, of the following form:

        n    the character in column n
        n-m  the characters in columns n through m
        n+m  m characters beginning at column n

where the columns in a line are numbered from 1 to the length of
the line.

   The use of delam is illustrated by the following examples.
The command

        delam 1-10,5 x.txt y.txt

reads standard input and writes characters 1 through 10 to file
x.txt and character 5 to file y.txt.  The command

        delam 10+5:1-10:1-10:80 mid x1 x2 end

writes characters 10 through 14 to mid, 1 through 10 to x1 and
x2, and character 80 to end.  The command

        delam 1-80,1-80 - -

copies standard input to standard output, replicating the first
eighty columns of each line twice.

Source code | Program Library Page | Icon Home Page