Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

fold (Unix)

From Wikipedia, the free encyclopedia
Unix command
fold
Original authorBill Joy
Initial release1977; 49 years ago (1977)
Operating systemUnix andUnix-like
PlatformCross-platform
TypeCommand
Licensecoreutils:GNU GPL v3

fold is aUnix command used for making afile with long lines more readable on a limited widthcomputer terminal by performing aline wrap.

MostUnix terminals have a default screen width of 80, and therefore reading files with long lines could get annoying. The fold command puts aline 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

[edit]

The utility first appeared in1BSD of 1977 and was originally written byBill Joy.[1][2]

fold is part of theX/Open Portability Guide since issue 4 of 1992. It was inherited into the first version of POSIX.1 and theSingle Unix Specification.[3]

The version offold bundled inGNUcoreutils was written by David MacKenzie.[4]

The command is available as a separate package forMicrosoft Windows as part of theUnxUtils collection ofnativeWin32ports of common GNU Unix-like utilities.[5]

Example

[edit]

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

$catfile.txtLorem 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.txtLorem 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 antepulvinar velit rhoncuslacinia. Morbi fringilla lacus quis arcu. Vestibulum sem quam, dapibus in,fringilla ut, venenatis ut, neque.

See also

[edit]

References

[edit]
  1. ^fold(1) – FreeBSD General CommandsManual
  2. ^"fold.c – 1BSD".minnie.tuhs.org.
  3. ^printf – Shell and Utilities Reference,The Single UNIX Specification, Version 5 fromThe Open Group
  4. ^"fold(1) - Linux man page".linux.die.net.Archived from the original on 2021-04-12. Retrieved2019-02-24.
  5. ^"Native Win32 ports of some GNU utilities".unxutils.sourceforge.net.Archived from the original on 2006-02-09. Retrieved2025-08-09.

External links

[edit]
The WikibookGuide to Unix has a page on the topic of:Commands
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
File system
Text utilities
Shell utilities
Retrieved from "https://en.wikipedia.org/w/index.php?title=Fold_(Unix)&oldid=1336332465"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp