Fold (Unix)

Last updated
fold
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

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

Related Research Articles

The editor war is the rivalry between users of the Emacs and vi text editors. The rivalry has become an enduring part of hacker culture and the free software community.

<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. Latin was originally a dialect spoken in Latium, the lower Tiber area around present-day Rome, but through the power of the Roman Republic it became the dominant language in the Italian region 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 18th century, when other regional vernaculars supplanted it in common academic and political usage. For most of the time it was used, it would be considered a "dead language" in the modern linguistic definition; that is, it lacked native speakers, despite being used extensively and actively.

xargs is a command on Unix and most Unix-like operating systems used to build and execute commands from standard input. It converts input from standard input into arguments to a command.

dd is a command-line utility for Unix, Plan 9, Inferno, and Unix-like operating systems and beyond, the primary purpose of which is to convert and copy files. On Unix, device drivers for hardware and special device files appear in the file system just like normal files; dd can also read and/or write from/to these files, provided that function is implemented in their respective driver. As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining a fixed amount of random data. The dd program can also perform conversions on the data as it is copied, including byte order swapping and conversion to and from the ASCII and EBCDIC text encodings.

sort (Unix) Standard UNIX utility

In computing, sort is a standard command line program of Unix and Unix-like operating systems, that prints the lines of its input or concatenation of all files listed in its argument list in sorted order. Sorting is done based on one or more sort keys extracted from each line of input. By default, the entire input is taken as sort key. Blank space is the default field separator. The command supports a number of command-line options that can vary by implementation. For instance the "-r" flag will reverse the sort order.

In computer programming, DLL injection is a technique used for running code within the address space of another process by forcing it to load a dynamic-link library. DLL injection is often used by external programs to influence the behavior of another program in a way its authors did not anticipate or intend. For example, the injected code could hook system function calls, or read the contents of password textboxes, which cannot be done the usual way. A program used to inject arbitrary code into arbitrary processes is called a DLL injector.

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

<span class="mw-page-title-main">Android (operating system)</span> Mobile operating system

Android is a mobile operating system based on a modified version of the Linux kernel and other open-source software, designed primarily for touchscreen mobile devices such as smartphones and tablets. Android is developed by a consortium of developers known as the Open Handset Alliance, though its most widely used version is primarily developed by Google. It was unveiled in November 2007, with the first commercial Android device, the HTC Dream, being launched in September 2008.

Toybox is a free and open-source software implementation of over 200 Unix command line utilities such as ls, cp, and mv. The Toybox project was started in 2006, and became a 0BSD licensed BusyBox alternative. Toybox is used for most of Android's command-line tools in all currently supported Android versions, and is also used to build Android on Linux and macOS. All of the tools are tested on Linux, and many of them also work on BSD and macOS.

The zero-width space (), abbreviated ZWSP, is a non-printing character used in computerized typesetting to indicate word boundaries to text-processing systems in scripts that do not use explicit spacing, or after characters that are not followed by a visible space but after which there may nevertheless be a line break. It is also used with languages without visible space between words, for example, Japanese. Normally, it is not a visible separation, but it may expand in passages that are fully justified.

<span class="mw-page-title-main">Glossary of ancient Roman religion</span>

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 in the Middle East throughout the history of the region, including its counterparts in other languages, such as Arabic Filasṭīn and Latin Palaestina.

<span class="mw-page-title-main">Windows Subsystem for Linux</span> Compatibility layer for running Linux binary executables natively on Windows

Windows Subsystem for Linux (WSL) is a feature of Windows that allows developers to run a Linux environment without the need for a separate virtual machine or dual booting. There are two versions of WSL: WSL 1 and WSL 2. WSL 1 was first released on August 2, 2016, and acts as a compatibility layer for running Linux binary executables by implementing Linux system calls on the Windows kernel. It is available on Windows 10, Windows 10 LTSB/LTSC, Windows 11, Windows Server 2016, Windows Server 2019 and Windows Server 2022.

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