-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

The Ultimate Linux Shell Scripting Guide
By :

Now that I’ve told you what expand
does, do I really need to tell you what unexpand
does? That’s right, you guessed it. unexpand
removes the blank spaces from between columns, and replaces them with tabs. There are a couple of slight catches, though. By default, unexpand
only operates on spaces that are at the beginning of a line. That’s just the opposite of how expand works with tabs. So, if you want to replace all spaces in a line with tabs, you’ll need to use the -a
switch. The second catch is that by default, unexpand
only works if it sees eight consecutive blank spaces. Any grouping of fewer than eight consecutive blank spaces won’t get converted to tabs. (You can change that behavior with the -t
switch, as you’ll see in a few moments.)
I’ll demonstrate by unexpanding the expand_2.txt
file that I’ve just created in the expand
section, using the -a
option, like so:
[donnie@fedora ~]$ unexpand -a expand_2...