Changes the format of a text file.
newform [ -s ] [ [ -f ] [ -a [ Number ] ] [ -b [ Number ] ] [ -c [ Character ] ] [ -e [ Number ] ] [ -i [ TabSpec ] ] [ -l [ Number ] ] [ -o [ TabSpec ] ] [ -p [ Number ] ] [ File ... ] ] ...
The newform command takes lines from the files specified by the File parameter (standard input by default) and writes the formatted lines to standard output. Lines are reformatted in accordance with the command-line flags in effect.
Except for the -s flag, you can enter command-line flags in any order, repeated, and mixed with the File parameter. Note, however, that the system processes command-line flags in the order you specify. For example, the -c flag modifies the behavior of the -a and -p flags, so specify the -c flag before the -p or -a flag for which it is intended. The -l (lowercase L) flag modifies the behavior of the -a, -b, -e, and -p flags, so specify the -l flag before the flags for which it is intended. For example, flag sequences like -e15 -l60 yield results that are different from -l60 -e15. Flags are applied to all files specified on the command line.
An exit value of 0 indicates normal execution; an exit value of 1 indicates an error.
Notes:
- The newform command normally only keeps track of physical characters; however, for the -i and -o flags, the newform command keeps track of backspaces to line up tabs in the appropriate logical columns.
- The newform command does not prompt you if the system reads a TabSpec variable value from standard input (by use of the -i- or -o- flag).
- If you specify the -f flag, and the last -o flag you specified was -o- preceded by either an -o- or an -i-, the tab-specification format line is incorrect.
- If the values specified for the -p, -l, -e, -a, or -b flag are not valid decimal numbers greater than 1, the specified value is ignored and default action is taken.
-a [ Number ] | Adds the specified number of characters to the end of the line when the line length is less than the effective line length. If no number is specified, the -a flag defaults to 0 and adds the number of characters necessary to obtain the effective line length. See also the -c [ Character ] and -p [ Number ] flags. |
-b [ Number ] | Truncates the specified number of characters from the beginning of the line if the line length is greater than the effective line length. If the line also contains fewer characters than specified by the Number parameter, the entire line is deleted and a blank line is displayed in its place.
See also the -I [ Number ] flag. If you specify the -b flag with no Number variable, the default action truncates the number of characters necessary to obtain the effective line length.
This flag can be used to delete the sequence numbers from a COBOL program, as follows: newform -l1-b7 file-name The -l1 flag must be used to set the effective line length shorter than any existing line in the file so that the -b flag is activated. |
-c [ Character ] | Changes the prefix/add character to that specified by the Character variable. Default character is a space and is available when specified before the -a and -p flags. |
-e [ Number ] | Truncates the specified number of characters from the end of the line. Otherwise, the flag is the same as the -b [ Number ] flag. |
-f | Writes the tab-specification format line to standard output before any other lines are written. The displayed tab-specification format line corresponds to the format specified by the final -o flag. If no -o flag is specified, the line displayed contains the default specification of -8. |
-i [ TabSpec ] | Replaces all tabs in the input with the number of spaces specified by the TabSpec variable.
This variable recognizes all tab specification forms described in the tabs command. If you specify a - (minus sign) for the value of the TabSpec variable, the newform command assumes that the tab specification can be found in the first line read from standard input. The default TabSpec value is -8. A TabSpec value of -0 expects no tabs. If any are found, they are treated as having a value of -1. |
-l [ Number ] | Sets the effective line length to the specified number of characters. If no Number variable is specified, the -l flag defaults to 72. The default line length without the -l flag is 80 characters. Note that tabs and backspaces are considered to be one character (use the -i flag to expand tabs to spaces). You must specify the -l flag before the -b and -e flags. |
-o [ TabSpec ] | Replaces spaces in the input with a tab in the output, according to the tab specifications given. The default TabSpec value is -8. A TabSpec value of -0 means that no spaces are converted to tabs on output. |
-p [ Number ] | Appends the specified number of characters to the beginning of a line when the line length is less than the effective line length. The default action is to append the number of characters that are necessary to obtain the effective line length. See also the -c flag. |
-s | Removes leading characters on each line up to the first tab and places up to 8 of the removed characters at the end of the line. If more than 8 characters (not counting the first tab) are removed, the 8th character is replaced by an * (asterisk) and any characters to the right of it are discarded. The first tab is always discarded.
The characters removed are saved internally until all other specified flags are applied to that line. The characters are then added to the end of the processed line. |
Note: The values for the -a, -b, -e, -l (lowercase L), and -p flags cannot be larger than LINE_MAX or 2048 bytes.
newform -s -i -l -a -e filename
The newform command displays the following error message and stops if the -s flag is used on a file without a tab on each line.
newform: 0653-457 The file is not in a format supported by the -s flag.
The tabs command, csplit command.