1

You can output the first n hex bytes of a file in Linux with xdd (xdd -ps, etc)

How would one do this on Windows, though? Is there a way?

2
  • take a look at this Question >>> Extract the first 50 bytes of a file using Powershell - Stack Overflow — stackoverflow.com/questions/60766774/… <<< you can convert the bytes into hex chars fairly directly. – Lee_Dailey May 6 at 15:20
  • the Answer posted by user1686 shows how to do that. – Lee_Dailey May 6 at 17:45
0

If you want a simple string of hex numbers:

[BitConverter]::ToString((Get-Content $file -Encoding Byte -TotalCount $nbytes))

If you want to get a "traditional" hexdump of a file:

Format-Hex $file

Both found via google.

1
  • The first example already does that. – user1686 May 6 at 16:29

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.