Freeing disk space with “>”

“The basic problem is that if another process has a file open
(for reading or writing, it doesn’t matter), the disk blocks are
not freed by an “rm” until the process or process using the file
quits (or stops using the file, at least). That part seems to be
well understood.

“What is perhaps more difficult to understand is why a simple
“>” CAN free up the bytes that “rm’ cannot.

“To show that, we need to write a little code. I’ll use Perl for
that, but if you don’t grok Perl, don’t worry -I’ll explain it as
we go along. I did this on a Mac, but you’d see the same thing on
Linux or BSD.

“Let’s start with the “rm” issue. Our Perl code will just open a
file and loop. We’ll run that in one Terminal window and do
everything else in another.”


Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis