fmt (Unix)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
fmt
Original authorAT&T Bell Laboratories
DevelopersVarious open-source and commercial developers
Repository
  • {{URL|example.com|optional display text}}Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    Operating systemUnix, Unix-like, Plan 9, Inferno
    PlatformCross-platform
    TypeCommand

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

    Overview

    [edit | edit source]

    The command has been used to reformat email messages after composition and before delivery. Its syntax is similar among various Unixes, but not identical. fmt attempts to break, fill, and join input lines to produce globally optimal, balanced output with the lengths of each line approaching the target width as closely as possible, rather than wrapping the input lines exactly as fold (from BSD and GNU Core Utilities) does.

    In most implementations of fmt, the word wrap optimization procedure usually requires two criteria: the target output line width and the maximum acceptable line width (which should be larger than the previous one to give room for optimization). It might not always be possible to give these two options simultaneously. For example, early versions of GNU fmt can only accept the maximum width option, which is given by the -w switch, or directly -digits as the first command line option for compatibility (later versions use -g to specify the goal width and -w for the maximum width). See the Solaris man page for fmt[1] and FreeBSD manual entry for fmt[2] for detailed examples, and compare with the latest documentation of the GNU fmt utility[3] included by most Linux distributions. See also the Plan 9 fmt man page.[4]

    Unlike par, fmt has no Unicode support and does not support text justification.

    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

    [edit | edit source]
    $ fmt -w 50 << END
    > Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur dignissim
    venenatis pede. Quisque dui dui, ultricies ut, facilisis non, pulvinar non. 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
    fringilla ut, venenatis ut, neque.s arcu. Vestibulum sem quam, dapibus in,
    > END
    Lorem ipsum dolor sit amet, consectetuer
    adipiscing elit. Curabitur dignissim
    venenatis pede. Quisque dui dui, ultricies ut,
    facilisis non, pulvinar non. 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.
    

    The width of each line is at most 50 characters and the text flows within this constraint.

    See also

    [edit | edit source]

    References

    [edit | edit source]
    1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    5. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    [edit | edit source]