DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

newform(C)


newform -- change the format of a text file

Syntax

newform [ -s ] [ -itabspec ] [ -otabspec ] [ -bn ] [ -en ] [ -pn ] [ -an ] [ -f ]
[ -cchar ] [ -ln ] [ file ... ]

Description

The newform command reads lines from the named files, or the standard input if no input file is named, and reproduces the lines on the standard output. Lines are reformatted in accordance with command line options in effect.

Except for -s, command line options may appear in any order, may be repeated, and may be intermingled with files. Command line options are processed in the order typed. This means that option sequences like ``-e15 -l60'' will yield results different from ``-l60 -e15''. Options are applied to all files on the command line.


-s
Shears off leading characters on each line up to the first tab and places up to 8 of the sheared characters at the end of the line. If more than 8 characters (not counting the first tab) are sheared, the eighth character is replaced by a ``*'' and any characters to the right of it are discarded. The first tab is always discarded.

An error message and program exit will occur if this option is used on a file without a tab on each line. The characters sheared off are saved internally until all other options specified are applied to that line. The characters are then added at the end of the processed line.


-itabspec
Input tab specification: expands tabs to spaces, according to the tab specifications given. tabspec recognizes all tab specification forms described below. In addition, tabspec may be ``--'', in which newform assumes that the tab specification is to be found in the first line read from the standard input. If no tabspec is given, tabspec defaults to -8. A tabspec of -0 expects no tabs; if any are found, they are treated as -1.

-otabspec
Output tab specification: replaces spaces by tabs, according to the tab specifications given. The tab specifications are the same as for -itabspec. If no tabspec is given, tabspec defaults to -8. A tabspec of -0 means that no spaces will be converted to tabs on output.

-bn
Truncates n characters from the beginning of the line when the line length is greater than the effective line length (see -ln). The default is to truncate the number of characters necessary to obtain the effective line length. The default value is used when -b with no n is used. This option can be used to delete the sequence numbers from a COBOL program as follows:

newform -l1 -b7 filename

The option -l1 must be used to set the effective line length shorter than any existing line in the file so that the -b option is activated.


-en
Truncates n characters from the end of the line.

-pn
Prefixes n characters (see -ck) to the beginning of a line when the line length is less than the effective line length. The default is to prefix the number of characters necessary to obtain the effective line length.

-an
Appends n characters to the end of a line. The default is to append the number of characters necessary to get the effective line length.

-f
Writes the tab specification format line on the standard output before any other lines are output. The tab specification format line which is printed will correspond to the format specified in the last -o option. If no -o option is specified, the line which is printed will contain the default specification of -8.

-ck
Changes the prefix/append character to k. Default character for k is a space (see options -p and -a).

-ln
Sets the effective line length to n characters. If n is not typed, -l defaults to 72. The default line length without the -l option is 80 characters. Note that tabs and backspaces are considered to be one character (use -i to expand tabs to spaces).

Tabs

Four types of tab specification are accepted for tabspec: ``canned'', repetitive, arbitrary, and file. The lowest column number is 1. For tabs, column 1 always refers to the leftmost column on a terminal, even one whose column markers begin at 0, for example the DASI 300, DASI 300S, and DASI 450.

The ``canned'' tabs are given as -code where code (and its meaning) is from the following list:


-a
1,10,16,36,72
Assembler, IBM S/370, first format

-a2
1,10,16,40,72
Assembler, IBM S/370, second format

-c
1,8,12,16,20,55
COBOL, normal format

-c2
1,6,10,14,49
COBOL compact format (columns 1-6 omitted). Using this code, the first typed character corresponds to card column 7, one space gets you to column 8, and a tab reaches column 12. Files using this tab setup should include a format specification as follows:

<:t-c2 m6 s66 d:>


-c3
1,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62,67
COBOL compact format (columns 1-6 omitted), with more tabs than COBOL -c2. This is the recommended format for COBOL. The appropriate format specification is:

<:t-c3 m6 s66 d:>


-f
1,7,11,15,19,23
FORTRAN

-p
1,5,9,13,17,21,25,29,33,37,41,45,53,57,61
PL/I

-s
1,10,55
SNOBOL

-u
1,12,20,44
UNIVAC 1100 Assembler
In addition to these ``canned'' formats, three other types exist:

-n
A repetitive specification requests tabs at columns 1+n, 1+2*n, etc. Note that such a setting leaves a left margin of n columns on TermiNet terminals only. Of particular importance is the value -8: this represents the UNIX system ``standard'' tab setting, and is the most likely tab setting found at a terminal. It is required for use with the nroff -h option for high-speed output. Another special case is the value -0, implying no tabs at all.

n1,n2, ...
The arbitrary format permits the user to type any chosen set of number, separated by commas, in ascending order. Up to 40 numbers are allowed. If any number (except the first one) is preceded by a plus sign, it is taken as an increment to be added to the previous value. Thus, the tab lists 1,10,20,30 and 1,10,+10,+10 are considered identical.

--file
If the name of a file is given, newform reads the first line of the file, searching for a format specification. If it finds one there, it sets the tab stops according to it; otherwise it sets them as -8. This type of specification may be used to make sure that a tabbed file is printed with correct tab settings.

Any of the following may be used also; if a given flag occurs more than once, the last value given takes effect:

-Ttype
newform usually needs to know the type of terminal in order to set tabs and always needs to know the type to set margins. type is a name listed in term(M). If no -T flag is supplied, newform searches for the $TERM value in the environment (see environ(M)). If no type can be found, newform tries a sequence that will work for many terminals.

+mn
The margin argument may be used for some terminals. It causes all tabs to be moved over n columns by making column n+1 the left margin. If +m is given without a value of n, the value assumed is 10. For a TermiNet, the first value in the tab list should be 1, or the margin will move even further to the right. The normal (leftmost) margin on most terminals is obtained by +m0. The margin for most terminals is reset only when the +m flag is given explicitly.

Exit values

0 -- normal execution
1 -- for any error

Diagnostics

All diagnostics are fatal.

usage: ...
newform was called with a bad option.

not -s format
There was no tab on one line.

can't open file
Self-explanatory.

internal line too long
A line exceeds 512 characters after being expanded in the internal work buffer.

tabspec in error
A tab specification is incorrectly formatted, or specified tab stops are not ascending.

tabspec indirection illegal
A tabspec read from a file (or standard input) may not contain a tabspec referencing another file (or standard input).

Examples

In the following example, newform converts a file named text with leading digits, one or more tabs, and text on each line to a file beginning with the text and the leading digits placed at the end of each line in column 73 (-s option). All tabs after the first one are expanded to spaces (-i option). To reach the line length of 72 characters (-l option), spaces are appended to each line up to column 72 (-a option) or lines are truncated at column 72 (-e option). To reformat the sample file text in this manner, enter:

newform -s -i -l -a -e text

Limitations

newform normally only keeps track of physical characters; however, for the -i and -o options, newform will keep track of backspaces in order to line up tabs in the appropriate logical columns.

newform will not prompt the user if a tabspec is to be read from the standard input (by use of -i, -- or -o--).

If the -f option is used, and the last -o option specified was ``-o--'', and was preceded by either ``-o--'' or a ``-i--'', the tab specification format line will be incorrect.

See also

csplit(C)
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003