[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Commands Reference, Volume 2

fold Command

Purpose

Folds long lines for finite-width output device.

Syntax

fold [ -b ] [ -s ] [ -w Width ] [ File... ]

Description

The fold command is a filter that folds long lines for a finite-width output device. By default, the command folds the contents of standard input, breaking the lines to a line width of 80 (eighty). You can also specify one or more files as input to the command.

The fold command inserts a new-line character in the input lines so that each output line is as wide as possible without exceeding the value specified by the Width parameter. If the -b flag is specified, line width is counted in bytes. If the -b flag is not specified:

The fold command accepts -w Width values in multiples of 8 if the file contains tabs. To use other width values when the file contains tabs, use the expand command before using the fold command.

Notes:
  1. The fold command may affect any underlining that is present.
  2. The fold command does not insert new-line characters in the middle of multibyte characters even when the -b flag is used.

Flags

-b Counts Width in bytes. The default is to count in columns.
-s Breaks the line after the rightmost blank within the Width limit, if an output line segment contains any blank characters. The default is to break lines so each output line segment is as wide as possible.
-w Width Specifies the maximum line width as the value of the Width variable. The maximum line width is 2048. The default is 80.

Exit Status

This command returns the following exit values:

0 All input files processed successfully.
>0 An error occurred.

Examples

To fold the lines of a file named longlines into width 72 (seventy-two), enter:

fold -w 72 longlines

Files

/usr/bin/fold Contains the fold command.

Related Information

The expand command, tab command.

Devices Overview for System Management in AIX Version 4.3 System Management Guide: Operating System and Devices.


[ Previous | Next | Contents | Glossary | Home | Search ]