It looks like you have multiple wierdnesses going on there.
In the first place, you are nesting a backtick-quoted command execution inside a %x{ ... } block. That will run the inner command, then (on success) run its output as a command. I don't suppose that's what you want.
In the second place, you have a quoting problem. Garet is onto something when he observes that the error is flagging a construct recognized by bash but not by the traditional Bourne shell. His suggestion is probably right, except that he neglects to mention that the whole body of the command needs to be quoted as a single argument following -c.
In the third place, your command has odd redirections in it: you redirect the diff output to a file, but you also pipe it to sed. There's only one standard output; you cannot redirect it to two different termini.
In the fourth place, you are both piping input into sed, and giving it a file name to process, and moreover, you are specifying in-place editing (-i). This combination should edit the named file, ignoring standard input and producing nothing on standard output. That's ok in itself, but it won't give you anything for your fact value.
Supposing that it is important to record the results of the command in a file, as the command seems intended to do, it looks like you want something like this: