Reading binary files in the Shell and friends
Table of Contents
In Powershell or the cmd.exe
prompt on Microsoft Windows, use the vim-office plug-in to display meaningful text of a binary files read by Vim.
On MacOS, Linux or in WSL / Git Bash on Microsoft Windows, to read a binary file not only in Vim, but more generally in less
, git
, mutt
, vim
or ranger
(and its variants lf
, nnn
or yazi
), you can use lesspipe.sh or lesspipe
(which comes installed on Debian and its derivatives, such as Ubuntu or Linux Mint).
See the lesspipe wiki on how to set up these tools for lesspipe to show read binary files.
To customize the text conversion, you can use run-mailcap (which comes installed on Debian and its derivatives, such as Ubuntu or Linux Mint) with a suitable ~/.mailcap file in which you can distinguish between the program displaying the text output, for example, less
, mutt
, vim
or ranger
(respectively lf
, nnn
or yazi
).
The conversion from a file in a binary format to text requires the installation of appropriate external converters such as unrtf, pandoc, docx2txt.pl, odt2txt, xlscat, xlsx2csv.py or pptx2md, but already LibreOffice or Tika can go a long way.
If you use Debian or one of its derivatives, such as Ubuntu or Linux Mint, this command installs some of these converters
apt install unrtf catdoc abiword xlsx2csv wv docx2txt odt2txt poppler-utils djvulibre-bin qpdfview p7zip-full