Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing some code that will apply the patch(1) program, and I want to completely prevent it from creating backup files. That is, I don't want it to create foo.orig files when it either fails to update a particular file (in which case it creates a foo.rej file), or when it successfully updates a file but there's some fuzziness involved, both of which it ordinarily does. This seems to be easier said than done.

Base case: I run "patch" against a Debian source directory, and it fails to update the debian/changelog file. patch creates a file debian/changelog.orig file (which is what I'm trying to avoid).

The documentation mentions a --no-backup-if-mismatch switch, which seems to be just what I need. But when I add it, the backup file is still created, only now it's called debian/changelog.~1~.

The documentation also says that when the --posix switch is present, backups will not be made. When I use this switch in place of --no-backup-if-mismatch, the backup file is still created, but with the original .orig suffix.

The only workaround I've found is to use the -B/--prefix switch to direct backups to be written to a directory of my choice. But this seems like an ugly hack. Isn't there a cleaner way to prevent backups?

share|improve this question
up vote 2 down vote accepted

Apparently -B/--prefix is the only way to go.

share|improve this answer

According to (diffutils)Backups, --no-backup-if-mismatch does what you want.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.