Linux and Unix fmt utility as a simple text formatter

fmt utility is a part of GNU core utilities and allows to reformat paragraph text writing to standard output. It also can read input from stdin.

Usage example:

Let’s assume you have big one-line text file (all words are placed in one single line and there are no returns characters there at all). In order to format this file with fmt just execute fmt /path/to/file and you’ll get 72 characters wide output like this:

viper@viper-laptop:~$ fmt /tmp/test
The GNU Project was launched in 1984 to develop a complete Unix-like
operating system which is free software: the GNU system. Variants of
the GNU operating system, which use the kernel called Linux, are now
widely used; though these systems are often referred to as “Linux”,
they are more accurately called GNU/Linux systems.

If you’d like to reduce line width and make it 40 chars wide just execute fmt -40 /path/to/file and you’ll get:

viper@viper-laptop:~$ fmt -40 /tmp/test
The GNU Project was launched in 1984 to
develop a complete Unix-like operating
system which is free software: the GNU
system. Variants of the GNU operating
system, which use the kernel called
Linux, are now widely used; though
these systems are often referred to as
“Linux”, they are more accurately
called GNU/Linux systems.

 
 
» You might also be interested in the following articles:
Manage gzip files on-the-fly (zcommands)
Secure shell (ssh) session timeout
Keep ssh session saved (Unix “screen” utility)
Two-way conversion of Unix time (seconds since 1970) and regular time
Simple way to transmit files over network (nc utility)



» Want to stay up to date? Subscribe to our E-MAIL or RSS feed!

5 Responses to “Linux and Unix fmt utility as a simple text formatter”


  1. 1 Annika Motayen

    Really value you writing post. Great.

  2. 2 Tarot barato

    Certainly I like your web site, but you have to test the spelling on quite a few of your posts. Several of them are rife with spelling issues and I find it very bothersome to inform you. However I will definitely come again again!

  3. 3 hkseo.us

    This always amazes me exactly how bloggers such as yourself can find some time and also the dedication to carry on producing superb discussions. Your blog iswonderful and one of my own must read blogs and forums. I simply want to say thanks.

  4. 4 affordable

    I think other site owners should take this web site as an model – very clean and great style and design, as well as the content. You’re an expert in this topic!

  5. 5 Coches de ocasion

    Whats up. Very cool web site!! Guy .. Excellent .. Superb .. I’ll bookmark your website and take the feeds additionally…I am satisfied to locate a lot of helpful info here in the post. Thank you for sharing…

Leave a Reply




Friendly Sites:Who is behind Linux Screw?
GeekyBits³ | Bash Cures Cancer | OMG! Ubuntu!
My SysAd Blog | Web Upd8
ZEPY | Linux config Wiki | Planet Sysadmin
a non-geek's linux notes | Linux Today
TuxArena: The arena of Tux | LinuxAlt.Com
My name is Artem N. (artiomix AT gmail DOT com) and I'm Linux/Unix, Cisco systems engineer. The main idea of Linux Screw is to share relevant knowledge, skills and observations over The Web. Here you can find a lot of information related to different Linux distributions, FreeBSD, IOS as well as a other Open Source around staff. Read more ››