Formatting with fmt

After you’ve been typing away—writing the Great American Novel, perhaps—you might notice that you’re suffering from creeping margin uglies, like those shown in Code Listing 6.21. Never fear, fmt can help. Just run your text through fmt, and all will be well.

To Format with fmt:

  • fmt spiderstory.unformatted

    At the shell prompt, just tell fmt to do its thing, and you’ll be in business.

✓ Tip

  • You can supplement fmt with handy flags to help make lines more readable. For example, you can often use fmt –u to make spacing uniform: one space between words, and two spaces between sentences. Or, try fmt –w to specify the width of the formatted text; for example, –w 60 would specify a 60-character-wide line.


Code Listing 6.21. With fmt you can clean up all kinds of idiosyncrasies in the format of your documents.
[jdoe@frazz jdoe]$ cat spiderstory.unformatted
This morning I
got up, went
downstairs, and found a HUMONGOUS spider
in the bathroom where the little potty is.
After I
quietly composed myself
from the shock (I didn't want
to alert the kids),

I looked around the
house for
something to put him in...the
kids' bug catcher thing
(nowhere to be found)...a jar...tupperware...a lidded
cup...the
salad spinner (BwaaaaHaaaHaaa!)....

I went back and checked on the spider and decided that I just couldn't face putting him in
something.
I mean, what if he got close to me...or TOUCHED
me?!?!
And, since I hate the crunching sound and feel of
squashing bugs,
I knew I couldn't just kill him.
This    spider had *bones*, I'm tellin' ya' So,I
hunted for bug spray.
And hunted. But
nothing.

[jdoe@frazz jdoe]$ fmt spiderstory.unformatted
This morning I got up, went downstairs, and found a HUMONGOUS spider in
the bathroom where the little potty is. After I quietly composed myself
from the shock (I didn't want to alert the kids),
I looked around the house for something to put him in...the kids' bug
catcher thing (nowhere to be found)...a jar...tupperware...a lidded
cup...the salad spinner (BwaaaaHaaaHaaa!)....
I went back and checked on the spider and decided that I just couldn't
face putting him in something.  I mean, what if he got close to me...or
TOUCHED me?!?!  And, since I hate the crunching sound and feel of
squashing bugs, I knew I couldn't just kill him. This spider had
*bones*, I'm tellin' ya'. So, I hunted for bug spary. And hunted.
But nothing.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.54.199