Talk:Fmt

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Differences between fold and fmt with respect to wrapping lines?[edit]

For example, using fold and fmt to wrap some text:

$ cat text 
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.
$ fold --spaces --width=50 text 
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.
$ fmt --width=50 text 
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.

The output is quite different. Using cat to have a look where each line ends:

$ fold --spaces --width=50 text | cat --show-ends
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.$
$ fmt --width=50 text | cat --show-ends
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.$

What about with text that wasn't already wrapped:

$ cat text
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.
$ fold --spaces --width=50 text | cat --show-ends
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.$
$ fmt --width=50 text | cat --show-ends
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.$

The output is still different, so fold and fmt do quite different wrappings of text. Could be shown. — Preceding unsigned comment added by 178.128.249.231 (talk) 17:15, 3 July 2012 (UTC)

Added example directly to Fold_(Unix) 173.63.95.40 (talk) 01:57, 30 December 2013 (UTC)