I know it's for the linux program patch, but if I try to use it, I get the following error:

missing header for unified diff at line 4 of patch

malformed patch at line 5: quit

Instead, I'd like to just cut out the middleman and edit it by hand, but I don't know what any of the symbols mean.


+ b/com.ibm.celldt.simulator.profile.default_3.1.0.200809010950/simulator_init.tcl
@@ -701,9 +701,9 @@ proc CellDT_ShutdownComplete { args } {

-mysim trigger set console "The system is going down for system halt NOW!" CellDT_ShutdownNotified
-mysim trigger set console "INIT: Switching to runlevel: 0" CellDT_ShutdownStarted
-mysim trigger set console "INIT: no more processes left in this runlevel" CellDT_ShutdownComplete
+mysim trigger set console "init: rcS main" CellDT_ShutdownNotified
+mysim trigger set console "Sending all processes the TERM signal" CellDT_ShutdownStarted
+mysim trigger set console "md: stopping all md devices." CellDT_ShutdownComplete

proc writeConsole { t } {
mysim console create console_id in string $t
@@ -740,8 +740,8 @@ proc CellDT_BootNearlyReady { args } {

mysim trigger set console "Starting Linux" CellDT_BootedBios
-mysim trigger set console "Welcome to Fedora Core" CellDT_BootedLinux
-mysim trigger set console "INIT: Entering runlevel: 2" CellDT_BootNearlyReady
+mysim trigger set console "Welcome to Fedora" CellDT_BootedLinux
+mysim trigger set console "Starting login process" CellDT_BootNearlyReady


4 Answers 4


Your output indicates the patch program is not properly interpreting the line starting with 'quit'. Each line added needs to start with '+'

Where did you get this file? These tools will assume and operate on "unix-style" newlines. That means all files that you're diffing and patching must have LF newlines only, and not the Windows/DOS standard CRLF newlines. Try:

dos2unix -d filename

Unified diff format: basically '-' means removed line, '+' means added line. So you can manually apply the patch if you want. But the best thing would be to resolve the underlying problem. Is the file segment you provide the complete file? If it is - it indicates that the diff header information is corrupt/missing, and you need to go back to the source/tools/process that created this patch.

  • As suggested, the file seems to be corrupted as the "original file" (a/com...) should be preceded with --- and the "new file" (b/com...) with +++ markers. (See an example via the link provided above.)
    – Jawa
    Apr 16, 2010 at 8:55

A fairly common problem is applying a patch for version x.yy.zzz to version x.yy.zza. That is, patch files are highly specific to particular versions of the source. I would strongly suggest that you post the actual program you're patching and the exact source of the patch.


It looks to me like your patch has the two main characters, ‘+’ and ‘-’, but it is missing the context marker ‘’ (space).

What probably happened is that you did a copy and paste from some website and the editor you used to fill in your text and save it into a file dropped the leading spaces. That's sort of broken, but can be fixed.

I personally prefer the save (link) as method, as it avoids manual post-processing work 99.95% of the time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy