Fold (Unix)

foldOperating system| Unix and Unix-like

|

Platform| Cross-platform
Type| Command
License| coreutils: GNU GPL v3

fold is a Unix command used for making a file with long lines more readable on a limited width computer terminal by performing a line wrap.

Most Unix terminals have a default screen width of 80, and therefore reading files with long lines could get annoying. The fold command puts a line feed every X characters if it does not reach a new line before that point. If the `-w` argument is set, the fold command allows the user to set the maximum length of a line.

## Contents

* 1 History
* 2 Example
* 3 See also
* 4 References
* 5 External links

## History

`fold` is part of the X/Open Portability Guide since issue 4 of 1992. It was inherited into the first version of POSIX.1 and the Single Unix Specification.[1] It first appeared in 1BSD of 1977.[2][3]

The version of `fold` bundled in GNU coreutils was written by David MacKenzie.[4]

The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.[5]

## Example

As a usage example, to fold a file named `file.txt` to have a maximum of 50 characters per line, one could run the following command:

fold -w 50 file.txt

* file.txt:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur dignissim
venenatis pede. Quisque dui dui, ultricies ut, facilisis non, pulvinar non,
purus. Duis quis arcu a purus volutpat iaculis. Morbi id dui in diam ornare
dictum. Praesent consectetuer vehicula ipsum. Praesent tortor massa, congue et,
ornare in, posuere eget, pede.

Vivamus rhoncus. Quisque lacus. In hac habitasse platea dictumst. Nullam mauris
tellus, sollicitudin non, semper eget, sodales non, pede. Phasellus varius
ullamcorper libero. Fusce ipsum lorem, iaculis nec, vulputate vitae, suscipit
vel, tortor. Cras varius.

Nullam fringilla pellentesque orci. Nulla eu ante pulvinar velit rhoncus
lacinia. Morbi fringilla lacus quis arcu. Vestibulum sem quam, dapibus in,
fringilla ut, venenatis ut, neque.

* output:

Lorem ipsum dolor sit amet, consectetuer adipiscin
g elit. Curabitur dignissim
venenatis pede. Quisque dui dui, ultricies ut, fac
ilisis non, pulvinar non,
purus. Duis quis arcu a purus volutpat iaculis. Mo
rbi id dui in diam ornare
dictum. Praesent consectetuer vehicula ipsum. Prae
sent tortor massa, congue et,
ornare in, posuere eget, pede.

Vivamus rhoncus. Quisque lacus. In hac habitasse p
latea dictumst. Nullam mauris
tellus, sollicitudin non, semper eget, sodales non
, pede. Phasellus varius
ullamcorper libero. Fusce ipsum lorem, iaculis nec
, vulputate vitae, suscipit
vel, tortor. Cras varius.

Nullam fringilla pellentesque orci. Nulla eu ante
pulvinar velit rhoncus
lacinia. Morbi fringilla lacus quis arcu. Vestibul
um sem quam, dapibus in,
fringilla ut, venenatis ut, neque.

## See also

* coreutils
* fmt (Unix)
* Par (command)
* List of Unix commands
* Text mode § PC common text modes

## References

1. ↑ `printf` – Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
2. ↑ `fold(1)` – FreeBSD General Commands Manual
3. ↑ "fold.c – 1BSD". https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s6/fold.c.
4. ↑ "fold(1) - Linux man page". https://linux.die.net/man/1/fold.
5. ↑ "Native Win32 ports of some GNU utilities". http://unxutils.sourceforge.net/.

## External links

* `fold(1)` – OpenBSD General Commands Manual
* `fold(1)` – FreeBSD General Commands Manual

* v
* t
* e

Unix command-line interface programs and shell builtins

File system|

* cat
* chmod
* chown
* chgrp
* cksum
* cmp
* cp
* dd
* du
* df
* file
* fuser
* ln
* ls
* mkdir
* mv
* pax
* pwd
* rm
* rmdir
* split
* tee
* touch
* type
* umask

Processes|

* at
* bg
* crontab
* fg
* kill
* nice
* ps
* time

User environment|

* env
* exit
* logname
* mesg
* talk
* tput
* uname
* who
* write

Text processing|

* awk
* basename
* comm
* csplit
* cut
* diff
* dirname
* ed
* ex
* fold
* head
* iconv
* join
* m4
* more
* nl
* paste
* patch
* printf
* sed
* sort
* strings
* tail
* tr
* uniq
* vi
* wc
* xargs

Shell builtins|

* alias
* cd
* echo
* test
* unset
* wait

Searching|

* find
* grep

Documentation|

* man

Software development|

* ar
* ctags
* lex
* make
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* expr
* lp
* od
* sleep
* true and false

* Categories
* Standard Unix programs
* Unix SUS2008 utilities
* List

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Fold (Unix). Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Fold_(Unix)&oldid=704027"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template