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 vim-common-7.0.109-7.el5
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 5e7f80888f3d491c4963881364048c24 joseph$ xxd -p /etc/passwd | xxd -r -p | md5 5e7f80888f3d491c4963881364048c24
Other tools that you may have a try with are hexdump, od, etc.