How to convert binary file to plain text?

Plain text files are easier to copy/paste and share compared to other types of files. How can we convert any non-plain text files like pictures, binary files, compressed files, etc to plain text?

Well, with the help of  vim, it’s quite easy. The command we use is ‘xxd’. xxd is part of vim-common in Linux distributions, and available in Mac OS X as well,

$ rpm -qf /usr/bin/xxd

To convert a file to hexdump,

$xxd -p /etc/passwd

To convert hexdump to its original format,

$ xxd -r -p file.hex.dump

This command will not bring any additional chars,

joseph$ cat /etc/passwd | md5
joseph$ xxd -p /etc/passwd | xxd -r -p | md5

Other tools that you may have a try with are hexdump, od, etc.

Share this post

Post Comment