I am running a program that creates a bunch of files in a certain directory, and I want to watch the files get created.
I open two terminal windows and cd one of them (call it terminal A) to the directory of the program (so I can run it) and the other (terminal B) to the directory where the output files get written (this output directory starts out empty). When I
Your program in terminal A probably deletes terminal B's current directory and then recreates it with the same name, so
ls doesn't work since that particular directory that was originally
cd'd to by terminal B doesn't exist anymore. However,
cd . brings you to the (now) re-created directory, at which point
ls works again.