Unix wizardry to get binary contents of a file as text?

I'm looking for an easy way to convert a simple binary to a textual representation of its binary, where the encoding doesn't matter. I know that the software solution is simple, but I feel that there must be some secret unix command line to achieve this.

Am I from the base? Is there a simpler solution than software?

+3
source share
8 answers

for example, to display a binary file as a sequence of hexadecimal codes:

od -t x1 file|cut -c8-
+6
source

Use od. For example:

$ od -t x1 -An /bin/ls | head
 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
 02 00 3e 00 01 00 00 00 e0 26 40 00 00 00 00 00
 40 00 00 00 00 00 00 00 30 b6 01 00 00 00 00 00
 00 00 00 00 40 00 38 00 09 00 40 00 1d 00 1c 00
 06 00 00 00 05 00 00 00 40 00 00 00 00 00 00 00
 40 00 40 00 00 00 00 00 40 00 40 00 00 00 00 00
 f8 01 00 00 00 00 00 00 f8 01 00 00 00 00 00 00
 08 00 00 00 00 00 00 00 03 00 00 00 04 00 00 00
 38 02 00 00 00 00 00 00 38 02 40 00 00 00 00 00
 38 02 40 00 00 00 00 00 1c 00 00 00 00 00 00 00
+7
source
base64 -e filename>xxx

base64 -d xxx>filename
+7

uuencode uudecode ASCII. . .

+6
max@upsight:~$ openssl base64 < /dev/urandom | head -10
qnISxigXTjgON+tkSDtRJ6fRNczsejY2bEC5D1W8fscy+6mopiGfVLvZ/bu99SrT
qdTRaeRXO8fgEejXsbTy4XP9MmCbAsBCSEvDpq5bfR/Sd7EjJLUxcRwzEMlhIrYT
m6J+20aR9M4g7pbT+hjjBE/gsHKxFfZQFgxT/tm1pEg6zMvQywjsrc7d+PSJQOHw
vzYXfWkyLO1nJm9g+Pw3rBI/UuV0+lmrIflhlj5CDWuaxDJUXJiWdsD6cGKLclfz
Mlh17mHwteqMLLSrTZ0QA0ygxISqiCf2sDtPgUToM7ZT2EbaNck5auxbhU+7OcxI
vBZRKozRZtfsZA0IUzMlIQmFanBdjOeGepQjgCDruq5hqEbNc1A+HhXqTtAr8Aic
4iNf36xZifDvASYy27hTVrlI/5kTeRZURqquaxHqum15VD5IC3J/sH+AwPpN1/qi
0YM8xt+LliVje7Oo7QiTona+VMjA//a715/0J8yeryLxTLSnT8JsXUpR0CiOgAcH
tQk9nzHCfMmFzb02nrhFJ0MjLCFgNJOiI1vT0AhNnMh449dcIkDDwyMpkRV4KZ1l
CSL+K4vXhMz3LhPKSihKbYLY6aJSnlPe/GiIOfl1g1VlbtoxJ7ZclpcOp4KWSKHV

... ..

+5

, , - , "", .

+1

hexdump. man- .

$ hexdump binaryfile
+1

, , . , Autonomy Keyview.

, (, MSOffice PDF).

-1

Source: https://habr.com/ru/post/1723909/


All Articles