Other Ways to Get Disk Space

Contents:
Instead of Removing a File, Empty It
Save Space with Bit Bucket Log Files and Mailboxes
Unlinking Open Files Isn't a Good Idea
Save Space with a Link
Limiting File Sizes
Save Space with Tab Characters
Compressing Files to Save Space
Save Space: tar and compress a Directory Tree
How Much Disk Space?
zloop: Run a Command on Compressed Files
Edit Compressed Files with zvi, zex, and zed
Compressing a Directory Tree: Fine-Tuning
Save Space in Executable Files with strip
Don't Use strip Carelessly
Trimming a Directory
Trimming a Huge Directory
Disk Quotas
Huge Files Might Not Take a Lot of Disk Space

Instead of Removing a File, Empty It

Sometimes you don't want to remove a file completely - you just want to empty it:

Well, you get the idea by now.

How can you empty a file? Watch out: when some editors say that a file has "no lines," they may still append a newline character when writing the file. Just one character still takes a block of disk space to store. Better:

You can also "almost" empty the file, leaving just a few lines, this way:

tail 
% tail afile > tmpfile % cat tmpfile > afile % rm tmpfile

That's especially good for log files that you never want to delete completely. Use cat and rm, not mv-mv will break the link to the original file (afile) and replace it with the temporary file.

- JP