I hope I understood your question well: you want to print ASCII characters from your hex dump that resembles the output of hexdump:

txt = '''
00000690 52 4D 41 50 00 00 01 00 08 00 00 00 08 00 00 00
000006A0 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000006B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000006C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000006D0 00 00 00 00 00 00 00 00 30 E0 01 04 90 9B 00 01
000006E0 B9 4D E9 46 5B 43 00 10 B2 BA FB 46 BA 24 13 16
000006F0 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
00000700 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '''

for line in txt.splitlines():
    if not line.strip():
        continue
    address, *nums = line.split()

    # printable ascii characters are from 32 to 127, else print a dot '.':
    print('{} {} {}'.format(address, ' '.join(nums), ''.join(chr(int(n, 16)) if 32 <= int(n, 16) <= 127 else '.' for n in nums)))

Prints:

00000690 52 4D 41 50 00 00 01 00 08 00 00 00 08 00 00 00 RMAP............
000006A0 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000006B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000006C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000006D0 00 00 00 00 00 00 00 00 30 E0 01 04 90 9B 00 01 ........0.......
000006E0 B9 4D E9 46 5B 43 00 10 B2 BA FB 46 BA 24 13 16 .M.F[C.....F.$..
000006F0 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ................
00000700 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Answer from Andrej Kesely on Stack Overflow
Top answer
1 of 2
2

I hope I understood your question well: you want to print ASCII characters from your hex dump that resembles the output of hexdump:

txt = '''
00000690 52 4D 41 50 00 00 01 00 08 00 00 00 08 00 00 00
000006A0 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000006B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000006C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000006D0 00 00 00 00 00 00 00 00 30 E0 01 04 90 9B 00 01
000006E0 B9 4D E9 46 5B 43 00 10 B2 BA FB 46 BA 24 13 16
000006F0 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
00000700 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '''

for line in txt.splitlines():
    if not line.strip():
        continue
    address, *nums = line.split()

    # printable ascii characters are from 32 to 127, else print a dot '.':
    print('{} {} {}'.format(address, ' '.join(nums), ''.join(chr(int(n, 16)) if 32 <= int(n, 16) <= 127 else '.' for n in nums)))

Prints:

00000690 52 4D 41 50 00 00 01 00 08 00 00 00 08 00 00 00 RMAP............
000006A0 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000006B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000006C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000006D0 00 00 00 00 00 00 00 00 30 E0 01 04 90 9B 00 01 ........0.......
000006E0 B9 4D E9 46 5B 43 00 10 B2 BA FB 46 BA 24 13 16 .M.F[C.....F.$..
000006F0 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ................
00000700 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
2 of 2
0

Assuming there is exactly one space character between two consecutive hexadecimal bytes, and between the offset and the first hexadecimal byte, in the input lines, a bash implementation would be:

$  cat hexdump-C 
#!/bin/bash

while read hex; do
# Delete offset
    ascii=" ${hex#* }"
# Replace non-printable bytes with a dot
    ascii=${ascii// [0189ABCDEF]?/.}
# Replace space characters with \x 
    ascii=${ascii// /\\x}
# printf replaces the \xhh sequences with the corresponding characters
    printf "ascii|\n"
done

--

$  cat data
00000690 52 4D 41 50 00 00 01 00 08 00 00 00 08 00 00 00  
000006A0 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   
000006B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   
000006C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   
000006D0 00 00 00 00 00 00 00 00 30 E0 01 04 90 9B 00 01   
000006E0 B9 4D E9 46 5B 43 00 10 B2 BA FB 46 BA 24 13 16 
000006F0 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00   
00000700 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

--

$  ./hexdump-C < data
00000690 52 4D 41 50 00 00 01 00 08 00 00 00 08 00 00 00 |RMAP............|
000006A0 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000006B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000006C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000006D0 00 00 00 00 00 00 00 00 30 E0 01 04 90 9B 00 01 |........0.......|
000006E0 B9 4D E9 46 5B 43 00 10 B2 BA FB 46 BA 24 13 16 |.M.F[C.....F.$..|
000006F0 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 |................|
00000700 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
🌐
RapidTables
rapidtables.com › convert › number › hex-to-ascii.html
Hex to String | Hex to ASCII Converter
Enter hex code bytes with any prefix / postfix / delimiter and press the Convert button (e.g. 45 78 61 6d 70 6C 65 21): * ASCII text encoding uses fixed 1 byte for each character. ** UTF-8 text encoding uses a variable number of bytes for each character. This requires a delimiter between each ...
Discussions

[01/14/13] Challenge #117 [Easy] Hexdump to ASCII
C# public void Easy117(string file) { var grouped = File.ReadAllBytes(file) .Select((x, i) => new {Index = i, Value = x}) .GroupBy(x => x.Index/18); foreach (var item in grouped) { Console.Write("{0:X8} ", item.Key); Console.WriteLine(string.Join(" ", item.Select(x => x.Value.ToString("X2")))); } } More on reddit.com
🌐 r/dailyprogrammer
95
59
January 14, 2013
Trying to find hex in bin file
If have or can install xxd, then you could filter the hex values from the ascii values of stdout, and still get a fairly good idea about the position in the file. xxd also lets you write back a hex dump to a binary. See: man xxd hth. More on reddit.com
🌐 r/bash
14
10
March 29, 2023
Real Time Hexdump Output
Hi there! I actually think what you're asking for is a fairly common use case in GR. I'll go ahead and say, it heavily depends on your signal. Is it WiFi? Something custom? Either way, you will need to have some kind of block that picks out the beginning and ends of your packet if you want to be able to divide them. Second, I 'think' you can convert those real values into bytes using a 'Float to Char' block, and then pump it into a UDP sink. Then look at it in something like Wireshark or Tcpdump. I don't have a complete picture of what you're trying to do. But that may at least get you the output you want. More on reddit.com
🌐 r/GNURadio
3
1
September 19, 2021
XOR of Hex
I have a C program which performs XOR of two hexadecimals You don't XOR two hexadecimals, you XOR a series of bits. Hexadecimal is just a numerical representation of a value. However I want to encrypt/decrypt a series of hex values with a given hex key instead of just the one number. what do you mean when you say: "a given hex key instead of just one number"? Any hexadecimal is just one number. So this doesn't make sense. I'm assuming that you want to XOR an array of bytes with another array of bytes. There are several ways to do this, depending on your plaintext-arrays and your key-arrays. If the key and plaintext are the same length, just loop through the arrays applying the XOR function to each byte in the array. More on reddit.com
🌐 r/C_Programming
6
0
February 27, 2021
🌐
Linux.org
linux.org › docs › man1 › hexdump.html
hexdump - display file contents in ascii, decimal, hexadecimal, or octal at Linux.org
-C Canonical hex+ASCII display. Display the input offset in hexadecimal, followed by sixteen space-sepa‐ rated, two-column, hexadecimal bytes, followed by the same sixteen bytes in %_p format enclosed in '|' characters. -d Two-byte decimal display. Display the input offset in hexadecimal, followed by eight space-separated, five-column, zero-filled, two-byte units of input data, in unsigned decimal, per line. -e format_string Specify a format string to be used for displaying data.
🌐
Quora
quora.com › How-do-I-interpret-a-hex-dump-in-ASCII-output
How to interpret a hex dump in ASCII output - Quora
Answer (1 of 2): Compiled code is not human-readable. It’s not meant to make sense to you, it’s meant to make sense to a CPU. You need to disassemble it, not display it as ASCII.
🌐
Reddit
reddit.com › r/dailyprogrammer › [01/14/13] challenge #117 [easy] hexdump to ascii
r/dailyprogrammer on Reddit: [01/14/13] Challenge #117 [Easy] Hexdump to ASCII
January 14, 2013 -

(Easy): Hexdump to ASCII

Hexadecimal is a base-16 representation of a number. A single byte of information, as an unsigned integer, can have a value of 0 to 255 in decimal. This byte can be represented in hexadecimal, from a range of 0x0 to 0xFF in hexadecimal.

Your job is to open a given file (using the given file name) and print every byte's hexadecimal value.

Author: PoppySeedPlehzr

Formal Inputs & Outputs

Input Description

As a program command-line argument to the program, accept a valid file name.

Output Description

Print the given file's contents, where each byte of the file must be printed in hexadecimal form. Your program must print 16 bytes per line, where there is a space between each hexadecimal byte. Each line must start with the line number, starting from line 0, and must also count in hexadecimal.

Sample Inputs & Outputs

Sample Input

"MyFile.txt" (This file is an arbitrary file as an example)

Sample Output

00000000 37 7A BC AF 27 1C 00 03 38 67 83 24 70 00 00 00
00000001 00 00 00 00 49 00 00 00 00 00 00 00 64 FC 7F 06
00000002 00 28 12 BC 60 28 97 D5 68 12 59 8C 17 8F FE D8
00000003 0E 5D 2C 27 BC D1 87 F6 D2 BE 9B 92 90 E8 FD BA
00000004 A2 B8 A9 F4 BE A6 B8 53 10 E3 BD 60 05 2B 5C 95
00000005 C4 50 B4 FC 10 DE 58 80 0C F5 E1 C0 AC 36 30 74
00000006 82 8B 42 7A 06 A5 D0 0F C2 4F 7B 27 6C 5D 96 24
00000007 25 4F 3A 5D F4 B2 C0 DB 79 3C 86 48 AB 2D 57 11
00000008 53 27 50 FF 89 02 20 F6 31 C2 41 72 84 F7 C9 00
00000009 01 04 06 00 01 09 70 00 07 0B 01 00 01 23 03 01
0000000A 01 05 5D 00 00 01 00 0C 80 F5 00 08 0A 01 A8 3F
0000000B B1 B7 00 00 05 01 11 0B 00 64 00 61 00 74 00 61
0000000C 00 00 00 14 0A 01 00 68 6E B8 CF BC A0 CD 01 15
0000000D 06 01 00 20 00 00 00 00 00

Challenge Input

Give your program its own binary file, and have it print itself out!

Challenge Input Solution

This is dependent on how you write your code and what platform you are on.

Note

  • As an added bonus, attempt to print out any ASCII strings, if such data is found in your given file.

Top answer
1 of 5
23
C# public void Easy117(string file) { var grouped = File.ReadAllBytes(file) .Select((x, i) => new {Index = i, Value = x}) .GroupBy(x => x.Index/18); foreach (var item in grouped) { Console.Write("{0:X8} ", item.Key); Console.WriteLine(string.Join(" ", item.Select(x => x.Value.ToString("X2")))); } }
2 of 5
11
Emacs Lisp, (defun slurp (file) (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents-literally file) (buffer-string))) (defun* hexdump (file &optional (width 18)) (interactive "fFile to dump: ") (loop for count upfrom 0 for byte across (slurp file) when (zerop (% count width)) do (insert (format "\n%08X" (/ count width))) do (insert (format " %02X" byte)))) Common Lisp, (defun hexdump (file &optional (width 18)) (with-open-file (stream file :element-type '(unsigned-byte 8)) (loop while (listen stream) for count upfrom 0 when (zerop (mod count width)) do (format t "~&~8,'0x" (/ count width)) do (format t " ~2,'0x" (read-byte stream))))) Clojure, (defn hexdump ([file] (hexdump file 18)) ([file width] (with-open [data (java.io.FileReader. file)] (loop [byte (.read data) counter 0] (when (>= byte 0) (if (zero? (mod counter width)) (printf "\n%08X" (/ counter width))) (printf " %02X" byte) (recur (.read data) (inc counter))))))) ANSI C, void hexdump(char *file, int width) { FILE *in = fopen(file, "r"); int c, counter = 0; while ((c = fgetc(in)) > -1) { if (counter++ % width == 0) printf("\n%08X", counter / width); printf(" %02X", c); } fclose(in); }
🌐
SysTutorials
systutorials.com › convert-hex-to-ascii-using-xxd
Converting Hex To ASCII With Xxd - SysTutorials
April 12, 2026 - The xxd -r -p combination remains the fastest and most portable way to convert hex strings to ASCII on the command line.
🌐
HexHero
hexhero.com › converters › hex-to-ascii
Hex to ASCII Converter
When examining hex dumps from executables, ROM chips, or hardware devices, ASCII-range values (00-7F) often reveal embedded text strings—copyright notices, error messages, debugging output, and configuration data. Security researchers use this technique to extract readable strings from compiled ...
Find elsewhere
🌐
Baeldung
baeldung.com › home › scripting › convert hex to ascii characters in the linux shell
Convert Hex to ASCII Characters in the Linux Shell | Baeldung on Linux
March 18, 2024 - Alternatively, we can use the dc command to convert a character from hex to ASCII. The dc stands for Desk Calculator. This command accepts the input in postfix notation form: ... P represents the Print command of dc.
🌐
Opensource.com
opensource.com › article › 19 › 8 › dig-binary-files-hexdump
How Hexdump works | Opensource.com
The raw data probably means nothing to you, but you already know how to convert it to ASCII: hexdump --canonical /usr/share/doc/libblkid-devel/COPYING 00000000 54 68 69 73 20 6c 69 62 72 61 72 79 20 69 73 20 |This library is | 00000010 66 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79 |free software; y| 00000020 6f 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 |ou can redistrib| 00000030 75 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a 6d 6f |ute it and/or.mo| 00000040 64 69 66 79 20 69 74 20 75 6e 64 65 72 20 74 68 |dify it under th| 00000050 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65 20 47 |e terms of the G| 00000060 4e 55 20 4c 65 73 73 65 72 20 47 65 6e 65 72 61 |NU Lesser Genera| 00000070 6c 20 50 75 62 6c 69 63 0a 4c 69 63 65 6e 73 65 |l Public.License| [...]
🌐
Duplichecker
duplichecker.com › hex-to-text.php
Hex to Text | Convert Hexadecimal to Text Online
With our hexadecimal to text converter, you can convert and understand lengthy numerical codes of hexadecimal easily.
🌐
GitHub
gist.github.com › ccbrown › 9722406
Compact C Hex Dump Function w/ASCII · GitHub
I revised it and removed usage of printf function. Instead, a string buffer (strBuffer) is used for each line. Also, DumpHex has third parameter - a pointer to a function that outputs the lines to the output (or to a file, or to a serial port or where the user wants to).
🌐
Linux Man Pages
man7.org › linux › man-pages › man1 › hexdump.1.html
hexdump(1) - Linux manual page
Display the input offset in hexadecimal, followed by sixteen space-separated, two-column, zero-filled bytes of input data, in hexadecimal, per line. -c, --one-byte-char One-byte character display. Display the input offset in hexadecimal, followed by sixteen space-separated, three-column, space-filled characters of input data per line. -C, --canonical Canonical hex+ASCII display.
🌐
Linux Handbook
linuxhandbook.com › convert-hex-ascii
Convert Hex to ASCII Characters in Linux Command Line
July 27, 2025 - Let's consider the following hex ... should look like this: Linuxhandbook 123 · xxd is a command-line utility that can create a hex dump from the given text and vice versa....
🌐
Tcl Wiki
wiki.tcl-lang.org › page › Dump+a+file+in+hex+and+ASCII
Dump a file in hex and ASCII
# data = binary data # start_addr ... 0} {width 8}} { set out "" if { [ catch { # Convert the data to hex and to characters. binary scan $data H*@0a* hex ascii # Replace non-printing characters in the data....
🌐
Coding
coding.tools › home › number conversion › hex to ascii
Hex to ASCII String Converter Online Tool
Convert hexadecimal byte values into ASCII text directly in your browser.
🌐
Caesar Cipher
caesarcipher.org › overview › learn › converters › hex to text conversion: ascii table, hex dumps & programming guide
Hex to Text Conversion: ASCII Table, Hex Dumps & Programming Guide
March 20, 2026 - If most bytes fall in the printable ASCII range (0x20-0x7E), it is likely text. If you see many values outside this range (especially 0x00, 0x80-0xFF), it is probably binary data. Hex dump tools show the ASCII interpretation alongside hex values to help you identify text within binary files.
🌐
SysTutorials
systutorials.com › docs › linux › man › 1-hexdump
Hexdump (1) Linux Manual Page - SysTutorials
May 19, 2026 - Canonical hex+ASCII display. Display the input offset in hexadecimal, followed by sixteen space-separated, two-column, hexadecimal bytes, followed by the same sixteen bytes in %_p format enclosed in ‘|‘ characters.
🌐
Online Tools
onlinetools.com › hex › convert-hex-to-ascii
Convert Hex to ASCII – Online Hex Tools
Free online hexadecimal to ASCII converter. Just load your hex numbers and they will automatically get converted to ASCII characters. There are no ads, popups or nonsense, just an awesome hex values to ASCII symbols converter. Load hexadecimal, get ASCII.