I am working in bash under Ubuntu 10.04 at the moment, but the solution would be interesting in other environments as well (e.g. Windows cmd.exe). I would typically rename the first file with a temporary name, rename the second file with the first name and finally rename the temporary file with the second name. Is there and idiom or program for doing this in one step?
$ mv file1 tmp; mv file2 file1; mv tmp file2