“fmt” Command Usage Examples in Linux

EXAMPLES

1. Given the contents of file file1.txt, fmt works as follows

$ cat file1.txt
abc
def
ghi
$ fmt file1.txt
abc def ghi

Simply using fmt formats text in a single line.

2. Let abc file contains some text, then giving a width of 1 produces output

$ cat abc
  This is a brief message to the Control Unit group.
     The new hp is now on-line. To send prints to it, type lj filename.
     If you have questions contact Sys. Adm. (x480).  The printer is
     located in the stock room.
$ fmt -w 1  abc
  This
  is
  a
  brief
  message
  to
  the
  Control
  Unit
  group.
     The
     new
     hp
     is
     now
     on-line.
     To
     send
     prints
     to
     it,
     type
     lj
     filename.
     If
     you
     have
     questions
     contact
     Sys.
     Adm.
     (x480).
     The
     printer
     is
     located
     in
     the
     stock
     room.

3. Crown Margin Mode

This example shows the crown margin usage.

$ cat abc
  This is a brief message to the Control Unit group.
     The new hp is now on-line. To send prints to it, type lj filename.
     If you have questions contact Sys. Adm. (x480).
     The printer is located in the stock room.
$ fmt -c abc
  This is a brief message to the Control Unit group.  The new hp is
     now on-line. To send prints to it, type lj filename.  If you have
     questions contact Sys. Adm. (x480).  The printer is located in the
     stock room.
Advertisements

Posted on June 17, 2015, in Linux (Ubuntu/CentOS). Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: