Originally Posted by sryzdn
I have not yet got the answer. If there are files in the directory, ls -laU will list the names of the files and >file will print the list in "file". Why should there be any notion of "zero length" file here?
First, the "file" is created by the shell before the "ls" command is executed. As a newly created file, it gets a zero length because no data is in the file...
Second, the data that will be put in the file is still in memory - it is all buffered in the application.
Now, if the directory has a LOT of files, (and this file is near the end of the list) you will see a non-zero length - but it still will not be complete until the last buffer is written.