• Uncategorized

About linux : xxd-usage-change-magic-byte-to-JPEG

Question Detail

I create a simple test file like this:

$ cat > test
blah

Now I run vi, and then :%!xxd to edit first bytes with FFD8 FF

00000000: ffd8 ffe0 0a                             blah.

and the I run :%!xxd -r.

file gives me NOT jpeg:

$ file test
test: Unicode text, UTF-8 text

And if I manage to get hexdump:

$ xxd test
00000000: c3bf c398 c3bf c3a0 0a                   .........

What am I doing wrong with xxd?
Thank you

Question Answer

When opening the file with vi, please make sure to say:

LC_ALL=C vi test

then edit and save the file with the shown procedure.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.