'\" te .\" Copyright 1989 AT&T .\" Copyright (c) 1995, 2011, Oracle and/or its affiliates.All rights reserved. .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation.Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation.In the following statement, the phrase "this text" refers to portions of the system documentation.Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document.The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.This notice shall appear on any product containing this material. .TH fold 1 "2011 年 8 月 17 日" "SunOS 5.11" "用户命令" .SH 名称 fold \- 折行过滤器 .SH 用法概要 .LP .nf \fBfold\fR [\fB-bs\fR] [\fB-w\fR \fIwidth\fR | \fB-width\fR] [\fIfile\fR]... .fi .SH 描述 .sp .LP \fBfold\fR 实用程序是一个在其输入文件中折行的过滤器,该过滤器通过换行使列位置最大为 \fIwidth\fR(如果指定了 \fB-b\fR 选项,则为最大字节数)。通过插入换行符进行换行,可使每个输出行(请参阅本节后面部分的段落)尽可能地接近最大宽度,而不会超出指定的列位置(或字节数)。不会在一个字符的中间换行。如果 \fIwidth\fR 小于输入中任何一个字符将占用的列数,则不定义该行为。 .sp .LP 如果在输入中出现回车符、退格符或制表符这些字符,且未指定 \fB-b\fR 选项,则会按以下方式对其进行特殊处理: .sp .ne 2 .mk .na \fB退格\fR .ad .RS 13n .rt 将行宽度的当前计数通过递减的方式减一,但计数不能变为负数。\fBfold\fR 不会在任何退格符前后紧挨着插入换行符。 .RE .sp .ne 2 .mk .na \fB回车符\fR .ad .RS 13n .rt 将行宽度的当前计数设置为 \fB0\fR。\fBfold\fR 不会在任何回车符前后紧挨着插入换行符。 .RE .sp .ne 2 .mk .na \fB制表符\fR .ad .RS 13n .rt 每出现一个制表符均会使列位置指针指向下一个制表停止位置。制表停止位置位于每个列位置 \fIn\fR(\fIn\fR 与 8 的模等于 1)处。 .RE .SH 选项 .sp .LP 支持以下选项: .sp .ne 2 .mk .na \fB\fB-b\fR\fR .ad .RS 19n .rt 计数 \fIwidth\fR 以字节数(而不是列位置)表示。 .RE .sp .ne 2 .mk .na \fB\fB-s\fR\fR .ad .RS 19n .rt 如果由一行组成的段在第一个 \fIwidth\fR 列位置(或字节数)内包含空白字符,将在符合宽度约束的最后一个此类空白字符之后换行。如果不存在符合要求的空白字符,则 \fB-s\fR 选项不会对输入行组成的该输出段产生任何影响。 .RE .sp .ne 2 .mk .na \fB\fB-w\fR \fIwidth\fR\fB|\fR\fB-\fR\fIwidth\fR\fR .ad .RS 19n .rt 按列位置(如果指定了 \fB-b\fR,则按字节数)指定最大行长度如果 \fIwidth\fR 不是十进制正数,将返回一个错误。缺省值为 80。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fB\fIfile\fR\fR\fR .ad .RS 8n .rt 要折行的文本文件的路径名称。如果未指定 \fIfile\fR 操作数,将使用标准输入。 .RE .SH 环境变量 .sp .LP 有关影响 \fBfold\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt 所有输入文件均已成功处理。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ CSIenabled(已启用) _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBcut\fR(1)、\fBpr\fR(1)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBstandards\fR(5) .SH 附注 .sp .LP \fBfold\fR 和 \fBcut\fR(1) 可用于将具有任意行长度的文件创建为文本文件。当长行的内容需要保持连续时,应使用 \fBfold\fR。当行数(或记录数)需要保持不变时,应使用 \fBcut\fR。 .sp .LP \fBfold\fR 通常用于将文本文件发送至行式打印机,该打印机将截断(而不是折叠)比打印机可打印的行宽度(通常位于列位置 80 或 132)更宽的行。 .sp .LP 如果存在下划线,则 \fBfold\fR 可能无法正常运行。