I'm trying to patch a file like this in bash:
cat << ''EOF | patch --dry-run
> --- urancid 2017-12-06 09:56:33.000000000 -0600 patch --dry-run
> +++ /tmp/urancid 2017-12-06 15:06:57.000000000 -0600
> @@ -393,7 +393,7 @@
> last if (/^$prompt/);
> next if (/-ac\.\s*/);
> next if (/-fs\.\s*/);
> - next if (/set date\s*/)
> + next if (/set date\s*/);
> next if (/^(\s*|\s*$cmd\s*)$/);
> if ( ! /^$prompt/) {
> if ( ! $skipprocess ) {
> EOF
but all I get is
patching file urancid
Hunk #1 FAILED at 393.
1 out of 1 hunk FAILED -- saving rejects to file urancid.rej
Seems like it should be possible, if I cat the patch file I'm pasting it works.
I want to do this so I can make a patch script without including multiple files.
I'm not too familiar with the what "patch" cares about as far, guessing there's some whitespace problems?
Best Answer
Fixing up the whitespace in your example so that the patch can apply demonstrates that the concept is acceptable (although I don't see why
cat
is needed).On the other hand, if you have a patch that has badly aligned whitespace, I'd suggest you use the
--ignore-whitespace
parameter. (You can find this in the man page for patch,man patch
.)