Quote:
Originally Posted by Unbeliever
Because the interpreter (the shell) loads the whole script and then executes it line by line. It would be really rather ineficient for it to repeatedly read a line and execute that line.
Ordinary shells behave like that, but ksh is much more efficient. To execute a loop, it ensures that it has the entire loop in core, then it
compiles the loop and then it executes the compiled code. Other shells need to re-interpret the code on each iteration. This the secret of ksh's speed.
More than that, despite the name, rm does not remove files, it unlinks them from directories. If the file has zero links and is not open by any process, it is removed. So the file will not disappear while ksh has it open. Instead, it becomes a file with zero file names. This behavior is a good way to handle temporary files and a lot of programs do that... create a file, unlink it, then use it. It is guaranteed to disappear upon program exit.
Newbie admins post fairly often saying that a big file ate their filesystem, they deleted it, and they did not get the space back. This is why that happens. The file is still consuming space and will until the process that has it opened is killed. And now the file has no name so it is much harder to deal with.