13
2
This is a code-golf question. You need to take the contents of two separate files (i.txt and o.txt) and swap them. You can create a third file to help you with the process, but have your program delete it after the file contents are swapped. Renaming the files is now allowed again.
Programs must work for any file content.
Shortest code wins, all eligible submissions will be up-voted.
2Rename the files. No need to "take the contents" and swap them to achieve the result. – Darren Stone – 2013-12-28T19:32:36.333
@Darren Stone I think that should be illegal. Thanks for catching that before answers were submitted. – None – 2013-12-28T19:33:17.160
Looks like a bad constraint, renaming is the best way to do this – hdante – 2013-12-28T20:47:18.007
1Alright, I can remove this constraint. – None – 2013-12-28T20:55:35.697
6@hdante but 'renaming files' is not exchanging their contents. On a system that uses
inodes the goal here would be fori.txt'sinodeto contain the data fromo.txt'sinode, and vice versa, so that if there are hardlinks to thoseinodes elsewhere, their contents will appear swapped as well. Renaming can't accomplish that. – AJMansfield – 2014-05-11T03:07:19.880