Xxd Usage (Change Magic Byte to Jpeg)

Xxd Usage (Change Magic Byte to Jpeg)

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

1 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.

Your Answer

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

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.