I have a file that should be a png but its signature is incorrect and therefore won't open. It's signature should be 8950 4e47 0d0a 1a0a but it is instead 8965 4e34 0d0a b0aa which makes it a.eN4 file. Is there any way to correct this in terminal?
You can use xxd
to do this.
I have a Vim mapping for it, but you can also purely do it with xxd
and your favourite editor:
xxd <bad_file >hexdump
Now edit hexdump
with your favourite editor. It is important that you edit the hexadecimal part, not the ASCII column on the right, which is only FYI. After you're done, save the file and do:
xxd -r <hexdump >good_file
I guess you could do it in one go:
xxd <bad_file | sed '1 s/8950 4e47 0d0a 1a0a/8965 4e34 0d0a b0aa/` | xxd -r >good_file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.