coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about fold


From: Bob Proulx
Subject: Re: Question about fold
Date: Mon, 15 Aug 2022 13:48:21 -0600

Pádraig Brady wrote:
> Moritz Poldrack wrote:
> > Pádraig Brady wrote:
> > > Both fold and fmt have overlapping functionality.
> > > fold is more lower level, using less context,
> > > and is operating as expected in this case.
> >
> > Thank you for your help. That's exactly what I wanted :) There are so
> > many coreutils one can lose track of them.
>
> It's a fair point that the relation is not obvious.
> I just pushed a change to fold(1) to SEE ALSO fmt(1).

As with many things the difference is in the history of how they were
created.  I remember fmt being specifically used with vi to perform
paragraph rewrapping.  Documentation on using vi would describe how to
use fmt with text to perform paragraph wrapping.  It was not built
into vi.  The typical example would be this.

    !}fmt

Also I remember (my way of saying I haven't researched it again now
for verification) that on HP-UX the fmt command was missing from the
operating system.  Instead HP-UX shipped an "adjust" command which was
similar to fmt but different.  At that time it was annoying that it
was different from fmt and so most of us in the field compiled fmt
from source and installed it as a local command so that we could use
fmt the same on all of our systems.  No idea why adjust was provided
instead of fmt on HP-UX.  Neither fmt nor adjust appears in standards.

Meanwhile the fold command was more related to pr types of actions
where one did not want the right side of text to be lost off the right
side of the printer.

Here Wikipedia has a good example of each which illustrates the
difference between them rather nicely when one compares the output
examples on the two pages.

    https://en.wikipedia.org/wiki/Fold_(Unix)
    https://en.wikipedia.org/wiki/Fmt_(Unix)

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]