home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 24.5 Limiting File Sizes Chapter 24
Other Ways to Get Disk Space
Next: 24.7 Compressing Files to Save Space
 

24.6 Save Space with Tab Characters

unexpand
The gzip ( 24.7 ) utility, and other utilities like compress , save space by squeezing text into a form that you can't read without uncompressing. If a file has lots of spaces in it - for example, columns with lots of space between them, or lines that are indented - you may be able to save space and keep the file readable too. Do that by changing the spaces to TAB characters with unexpand . If it's not on your system, get it from the CD-ROM.

How does it work? Article 41.4 introduces TAB handling on UNIX. Each TAB character can replace as many as eight space characters. By default, unexpand only changes spaces to TABs at the left margin. With the -a option, it changes spaces wherever it can (without changing the column positions of any text, of course). Comparing ls -l listings of a file before and after unexpand ing will tell you how much you've saved; the amount will vary file by file.

There are a few gotchas:

  • Your screen might not have tabstops every eight characters, so use cat to send an unexpand ed file to your screen; be sure the file looks the same as it did when it had spaces.

  • If you're sending the file to someone else, that person may have screen problems too. You might want to expand ( 41.4 ) the TABs before you send the file.

  • Editing a file with TABs can be tough. Just expand before editing and unexpand when you're done.

- JP


Previous: 24.5 Limiting File Sizes UNIX Power Tools Next: 24.7 Compressing Files to Save Space
24.5 Limiting File Sizes Book Index 24.7 Compressing Files to Save Space

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru