Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a program which displays incoming data which is delimited by a null character (^A). I am accessing the server it is running on via PuTTY and When I open a log in a text editor these are visible, however the null characters seem to be skipped when displayed from standard output, and this makes the data very hard to interpret as it is impossible to distinguish where one field ends and the other begins, is there any way I can configure PuTTY to display SOMETHING when a null character is printed to standard output?

Edit: example in PuTTY (portions of FIX protocol if anyone is curious)


How a message looks in vi (^A shows up in blue making it much easier to read):


And ideally if i replace null with say a space it is finally somewhat understandable from a glance:

14=0 15=USD 17=801000096 20=0 22=1 29=1 30=O 31=158.927881 32=3200 37=0000000000 38=0 39=2
share|improve this question
Can't you use tr or sed to make them visible before feeding to the editor? Vim could also filter the input ... – 0xC0000022L Mar 8 '13 at 20:58
I would ideally like to see them in the shell without having to use an editor. I can open the log files with an editor and null chars are visible so the messages are readable, however there is a significant delay from when a message is sent and when it is logged, and I often need to immediately interpret messages as they come in... – Shouvik Sayef Mar 8 '13 at 21:01
^A is not the null character, the null character is ^@. ^A is the first character after the null character. – Darth Android Mar 8 '13 at 21:41
So I have found this is impossible without modifying the program. 001 is the SOH character is not displayed in any character set. In terms of modifying the logs the tr command did the trick. Thank you – Shouvik Sayef Mar 13 '13 at 14:52

Substitute the unprintable charaters with something readable.


$ find  -print0


$ find  -print0 | sed 's/\0/  /g'
../  3.lines./  4.lines./  2.lines./  1.lines$
share|improve this answer

Use stdbuf (from coreutils) and tr:

$ while true; do printf "ASDF\001"; sleep 0.5; done | stdbuf -o0 tr '\001' ' '

Note: stdbuf is not needed when replacing with a newline, ie tr '\001' '\n'

Or, use awk/gawk

$ while true; do printf "ASDF\001"; sleep 0.5; done | awk 'BEGIN{RS="\001"}; {printf "%s ", $0}'

This works irrespective of terminal. See What is buffering... for more information.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.