Reputation: 1141
This question has already been asked in many different forms. I need to convert a file that looks like this
41 20 42 20 43 20 44
to this
A B C D
This is just an example, but files WILL certainly contain non-printable characters.
I wrote a simple piece of code in C
that does this, but I'm curious can it be done with some of the basic tools that are available on most Linux
distributions, such as dd
or tr
, or maybe some clever bash script?
Upvotes: 0
Views: 662
Reputation: 81012
For the sample input this works (in bash at least). Whether it will work for all input I'm not sure but I expect it probably will.
printf %b $(printf '\\x%s ' $(< infile)); echo
Upvotes: 1