Fold (Unix)

Last updated
fold
Original author(s) Bill Joy
Initial release1977;47 years ago (1977)
Operating 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.

Contents

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.

History

The utility first appeared in 1BSD of 1977 and was originally written by Bill Joy. [1] [2]

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

$ catfile.txt Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur dignissimvenenatis pede. Quisque dui dui, ultricies ut, facilisis non, pulvinar non,purus. Duis quis arcu a purus volutpat iaculis. Morbi id dui in diam ornaredictum. Praesent consectetuer vehicula ipsum. Praesent tortor massa, congue et,ornare in, posuere eget, pede.Vivamus rhoncus. Quisque lacus. In hac habitasse platea dictumst. Nullam mauristellus, sollicitudin non, semper eget, sodales non, pede. Phasellus variusullamcorper libero. Fusce ipsum lorem, iaculis nec, vulputate vitae, suscipitvel, tortor. Cras varius.Nullam fringilla pellentesque orci. Nulla eu ante pulvinar velit rhoncuslacinia. Morbi fringilla lacus quis arcu. Vestibulum sem quam, dapibus in,fringilla ut, venenatis ut, neque.$ fold-w50file.txt Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur dignissimvenenatis pede. Quisque dui dui, ultricies ut, facilisis non, pulvinar non,purus. Duis quis arcu a purus volutpat iaculis. Morbi id dui in diam ornaredictum. Praesent consectetuer vehicula ipsum. Praesent tortor massa, congue et,ornare in, posuere eget, pede.Vivamus rhoncus. Quisque lacus. In hac habitasse platea dictumst. Nullam mauristellus, sollicitudin non, semper eget, sodales non, pede. Phasellus variusullamcorper libero. Fusce ipsum lorem, iaculis nec, vulputate vitae, suscipitvel, tortor. Cras varius.Nullam fringilla pellentesque orci. Nulla eu ante pulvinar velit rhoncuslacinia. Morbi fringilla lacus quis arcu. Vestibulum sem quam, dapibus in,fringilla ut, venenatis ut, neque.

See also

Related Research Articles

<span class="mw-page-title-main">Latin</span> Indo-European language of the Italic branch

Latin is a classical language belonging to the Italic branch of the Indo-European languages. Classical Latin is considered a dead language as it is no longer used to produce major texts, while Vulgar Latin evolved into the Romance Languages. Latin was originally spoken in Latium, the lower Tiber area around Rome, Italy. Through the expansion of the Roman Republic it became the dominant language in the Italian Peninsula and subsequently throughout the Roman Empire. Even after the fall of Western Rome, Latin remained the common language of international communication, science, scholarship and academia in Europe until well into the early 19th century, when regional vernaculars supplanted it in common academic and political usage—including its own descendants, the Romance languages.

In computing, tar is a computer software utility for collecting many files into one archive file, often referred to as a tarball, for distribution or backup purposes. The name is derived from "tape archive", as it was originally developed to write data to sequential I/O devices with no file system of their own, such as devices that use magnetic tape. The archive data sets created by tar contain various file system parameters, such as name, timestamps, ownership, file-access permissions, and directory organization. POSIX abandoned tar in favor of pax, yet tar sees continued widespread use.

<span class="mw-page-title-main">Sapphic stanza</span> Four-line stanza form

The Sapphic stanza, named after Sappho, is an Aeolic verse form of four lines. Originally composed in quantitative verse and unrhymed, since the Middle Ages imitations of the form typically feature rhyme and accentual prosody. It is "the longest lived of the Classical lyric strophes in the West".

<span class="mw-page-title-main">ReactOS</span> Free incomplete Windows NT-like operating system

ReactOS is a free and open-source operating system for i586/amd64 personal computers intended to be binary-compatible with computer programs and device drivers developed for Windows Server 2003 and later versions of Microsoft Windows. ReactOS has been noted as a potential open-source drop-in replacement for Windows and for its information on undocumented Windows APIs.

A fat binary is a computer executable program or library which has been expanded with code native to multiple instruction sets which can consequently be run on multiple processor types. This results in a file larger than a normal one-architecture binary file, thus the name.

<span class="mw-page-title-main">BusyBox</span> Collection of Unix tools

BusyBox is a software suite that provides several Unix utilities in a single executable file. It runs in a variety of POSIX environments such as Linux, Android, and FreeBSD, although many of the tools it provides are designed to work with interfaces provided by the Linux kernel. It was specifically created for embedded operating systems with very limited resources. The authors dubbed it "The Swiss Army knife of Embedded Linux", as the single executable replaces basic functions of more than 300 common commands. It is released as free software under the terms of the GNU General Public License v2, after controversially deciding not to move to version 3.

In word processing and digital typesetting, a non-breaking space, also called NBSP, required space, hard space, or fixed space, is a space character that prevents an automatic line break at its position. In some formats, including HTML, it also prevents consecutive whitespace characters from collapsing into a single space. Non-breaking space characters with other widths also exist.

Technical variations of Linux distributions include support for different hardware devices and systems or software package configurations. Organizational differences may be motivated by historical reasons. Other criteria include security, including how quickly security upgrades are available; ease of package management; and number of packages available.

Line breaking, also known as word wrapping, is breaking a section of text into lines so that it will fit into the available width of a page, window or other display area. In text display, line wrap is continuing on a new line when a line is full, so that each line fits into the viewable window, allowing text to be read from top to bottom without any horizontal scrolling. Word wrap is the additional feature of most text editors, word processors, and web browsers, of breaking lines between words rather than within words, where possible. Word wrap makes it unnecessary to hard-code newline delimiters within paragraphs, and allows the display of text to adapt flexibly and dynamically to displays of varying sizes.

<span class="mw-page-title-main">FreeBSD</span> Free and open-source Unix-like operating system

FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version of FreeBSD was released in 1993 developed from 386BSD and the current version runs on IA-32, x86-64, ARM, PowerPC and RISC-V processors. The project is supported and promoted by the FreeBSD Foundation.

The fmt command in Unix, Plan 9, Inferno, and Unix-like operating systems is used to format natural language text for humans to read.

The zero-width space (ZWSP) is a non-printing character used in computerized typesetting to indicate where the word boundaries are, without actually displaying a visible space in the rendered text. This enables text-processing systems for scripts that do not use explicit spacing to recognize where word boundaries are for the purpose of handling line breaks appropriately. Zero-width space is unicode character U+200B, and is located in the unicode General Punctuation block, and can be represented by numeric character references &#x200B; or &#8203;.

The vocabulary of ancient Roman religion was highly specialized. Its study affords important information about the religion, traditions and beliefs of the ancient Romans. This legacy is conspicuous in European cultural history in its influence on later juridical and religious vocabulary in Europe, particularly of the Christian Church. This glossary provides explanations of concepts as they were expressed in Latin pertaining to religious practices and beliefs, with links to articles on major topics such as priesthoods, forms of divination, and rituals.

Timeline of the name <i>Palestine</i> Historical usage of Palestine as a place name

This article presents a list of notable historical references to the name Palestine as a place name for the region of Palestine throughout history. This includes uses of the localized inflections in various languages, such as Arabic Filasṭīn and Latin Palaestina.

The main Latin tenses can be divided into two groups: the present system, consisting of the present, future, and imperfect; and the perfect system, consisting of the perfect, future perfect, and pluperfect.

References

  1. fold(1)    FreeBSD General Commands Manual
  2. "fold.c – 1BSD". minnie.tuhs.org.
  3. printf   Shell and Utilities Reference, The Single UNIX Specification , Version 4 from The Open Group
  4. "fold(1) - Linux man page". linux.die.net.
  5. "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.