in order to see the header of file (wmv,mp3, binary[pe/elf/machos], avi, etc....) which command line in unix could perform this ?
looking forward for some answers :D
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityI generally use od -bc {filename} | head
to look at the header of a binary file. view
works too, but I find that it is generally better to see the output directly on the terminal.
The question is a bit wide in scope, so the suggestion is to approach in steps.
See also: ffmpeg command line options
head
will show the first few lines of code in a file.
A 'good' way of getting it into hex, pull the file into gvim and in the 'menu' (if you don't like typing abstract commands) there is an option to put the data through xxd getting it into hex. This is a good universal place to open a file like this as you'll be able to copy/paste plus have all of the wonderful tools of vim
at your fingertips!
Edit:
Just for completeness... Also you can do this directly in vim using xxd. I've used something similar to do binary patches to files.
vim <file> //opens the files
:%!xxd //feeds the current buffer through xxd and shows the resulting hexdump
<edit your file in vim> //be sure to keep alignment of bytes in the "hex" portion (the text side doesn't matter)
:%!xxd -r //take the hexdump back to the binary file
Identify is also useful for images:
Identify describes the format and characteristics of one or more image files. It will also report if an image is incomplete or corrupt. The information displayed includes the scene number, the file name, the width and height of the image, whether the image is colormapped or not, the number of colors in the image, the number of bytes in the image, the format of the image (JPEG, PNM, etc.), and finally the number of seconds it took to read and process the image.
For ELF files, I guess that readelf
is recommended.
For instance:
$ readelf -h ELF_FILE
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0x15565
Start of program headers: 52 (bytes into file)
Start of section headers: 2919696 (bytes into file)
Flags: 0x5000402, Version5 EABI, hard-float ABI, <unknown>
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 40 (bytes)
Number of section headers: 39
Section header string table index: 36
file
command?