output redirection in UNIX
Because
ls
reads all the names and sorts them before printing anything, and because the output file is created before the command is executed, at the time whenls
checks the size oftemp
, it is empty, so it shows up in the list as an empty file.When
wc
reads the file, it is empty, so it reports 0 characters in 0 words on 0 lines, and writes this information into the file after it has finished reading the empty file.