I am looking for a program that takes a file name (e.g. as an argument), reads from stdin into a buffer, and compares this with the contents of the named file.If the contents differ, the program (ideally atomically) overwrites the file with the contents of the input buffer.Otherwise, it leaves the file unchanged - no write occurs, no change of last-modified timestamp, and without generating a temporary file.Example Usage: echo test | myprogram myfile.txtDoes this program exist as a common Unix command line tool? Is there some nice way to achieve this tersely in the shell without a temporary file? (rsync do otherwise)
Replace file if and only if stdin differs from file contents
shell;files;pipe;file copy;diff