I have a file with .dat extension how can i view the contents of the file in hexa ? mean if i open the file i should be able to see the contents in hex format, can this be done using vim editor. I have installed tnef but when i try opening this dat file it says "Seems not to be a TNEF file"
16 Answers
Some common Linux utilities for viewing hex dumps are:
- xxd
- hexdump
Firstly, the dat file can be anything.
Use file <yourfile>.dat to find what it is. Then depending out its type, use specific application to open it.
mplayer <yourfile>.dat
gedit <yourfile>.dat file is a good command to try first.
After that, I use cat -v | less or od -a | less for a "readable" view.
Check the man pages for od and file.
xxd is more modern than od, and often generates a prettier view, but sometimes only od is available.
Of course mc (in many serious distros available from basic install CD) has HEX viewer. It can be accessed id view mode by F4
can this be done using vim editor[?].
Here's one way, from some blog Google found
So, open a file in vi as usual, hit escape and type:
:%!xxdto switch into hex modeAnd when your [sic] done hit escape again and type:
:%!xxd -rto exit from hex mode.Okay, so this isn’t actaully switching to vi’s ‘hex mode’; vi doesn’t have one. What the above actually does is to stream vi’s buffer through the external program ‘xxd’.
A commenter added
Try adding the following to
/etc/vim/vimrc.local, and you’ll get keyboard shortcuts for switching back and forth (F8 and F7)." Switch to hex-editor` noremap <F8> :%!xxd<CR> " Switch back noremap <F7> :%!xxd -r<CR>
There is also a Vim tip on this subject.
rename the file. like abc.dat to abc.pdf it will show the contents.
1