命令行大全

newform

rose1 发表于 2020-10-12 09:06浏览次数:

在Solaris上,newform命令修改文本文件的格式。

查看英文版

目录:

1 newform 运行系统环境

2 newform 说明

3 newform 语法

4 newform 例子

newform 运行系统环境

Linux

newform 说明

newform从命名的文件名中读取行,如果没有输入文件被命名,则从标准输入中读取行,并在标准输出中重现这些行。根据指定的命令行选项重新格式化行。

-s外,命令行选项可以按任何顺序出现,可以重复并且可以与可选文件名混合在一起。命令行选项按指定的顺序处理。这意味着像“ -e15 -l60 ”这样的选项序列将产生与“ -l60 -e15 ”不同的结果。选项适用于命令行上的所有文件名。

newform reads lines from the named filenames, or the standard input if no input file is named, and reproduces the lines on the standard output. Lines are reformatted in accordance with the specified command lineoptions.

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

查看英文版

查看中文版

newform 语法

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

选件

-s 剪切每行上的前导字符,直到第一个选项卡,并在该行的末尾最多放置8个剪切后的字符。如果剪切了8个以上的字符(不包括第一个选项卡),则将第一个字符替换为*,并丢弃其右边的任何字符。第一个选项卡始终被丢弃。
如果在每行上都没有选项卡的文件上使用此选项,则会出现错误消息并退出程序。剪切掉的字符在内部保存,直到指定的所有其他选项都应用到该行。然后将字符添加到已处理行的末尾。

例如,要将具有前导数字,一个或多个选项卡以及每行文本的文件转换为以文本开头的文件,则第一个选项卡之后的所有选项卡都将扩展为空格,并在第72列之前填充空格(或截断为第72列),并且前导数字从第73列开始放置,命令为:

newform -s -i -l -a -e filename
-i选项卡 输入制表符规范:根据给定的制表符规范,将制表符扩展为空格。该则tabspec识别的所有的标签规范形式的标签。此外,tabspec可能是-,其中newform假定将在从标准输入读取的第一行中找到制表符规范。如果没有则tabspec给出,则tabspec默认为-8。甲则tabspec的-0期望没接片; 如果找到,则将其视为-1。
输出制表符规范:根据给定的制表符规范,用制表符替换空格。选项卡规范与-i tabspec相同。如果没有则tabspec给出,则tabspec默认为-8。tabspec的-0表示在输出时没有空格将转换为tabs。
-bn 当行长大于有效行长时,请从行首截断n个 字符(请参见-l n)。默认值是截断获得有效行长所需的字符数。使用不带n的-b时,将使用缺省值。此选项可用于从COBOL程序中删除序列号,如下所示:

newform -l1 -b7 filename
-en -b n相同,除了字符从行尾开始被截断。
-pn 当行长小于有效行长时,在行首添加n个字符(请参阅-cchar)。默认值是为获得有效行长所需的字符数前缀。
-an -p n相同,只不过在行的末尾附加了字符。
-f 在输出任何其他行之前,在标准输出上写制表符规范格式行。打印的选项卡规范格式行将与最后一个-o选项中指定的格式相对应。如果未指定-o选项,则打印的行将包含默认规范8。
-cchar 将前缀/追加字符更改为char。char的默认字符为空格。
-ln 将有效行长度设置为n个字符。如果未输入n,则-l缺省为72。不带-l选项的默认行长是80个字符。注意:制表符和退格键被视为一个字符(使用-i将制表符扩展为空格)。

-l1必须用来设置有效行长度比文件中的任何现有线,使得较短的-b选项被激活。
newform [-s] [-itabspec] [-otabspec] [-bn] [-en] [-pn] [-an] [-f] 
        [-cchar] [-ln] [filename]...

Options

-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.

For example, to convert a file with leading digits, one or more tabs, and text on each line, to a file beginning with the text, all tabs after the first expanded to spaces, padded with spaces out to column 72 (or truncated to column 72), and the leading digits placed starting at column 73, the command would be:

newform -s -i -l -a -e filename
-itabspec Input tab specification: expands tabs to spaces, according to the tab specifications given. The tabspec recognizes all tab specification forms described in tabs. Also, 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.
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 Truncate n characters from the beginning of the line when the line length is greater than the effective line length (see -ln). 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
-en Same as -bn except that characters are truncated from the end of the line.
-pn Prefix n characters (see -cchar) to the beginning of a line when the line length is less than the effective line length. Default is to prefix the number of characters necessary to obtain the effective line length.
-an Same as -pn except characters are appended to the end of a line.
-f Write the tab specification format line on the standard output before any other lines are output. The tab specification format line that is printed will correspond to the format specified in the last -o option. If no -o option is specified, the line that is printed will contain the default specification of 8.
-cchar Change the prefix/append character to char. Default character for char is a space.
-ln Set the effective line length to n characters. If n is not entered, -l defaults to 72. The default line length without the -l option is 80 characters. Note: Tabs and backspaces are considered to be one character (use -i to expand tabs to spaces).

The -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.

查看英文版

查看中文版

newform 例子

newform -f myfile.txt

显示文件myfile.txt的选项卡规范。

newform -f myfile.txt

Display the tab specification of the file myfile.txt.

查看英文版

查看中文版