EN VI

Linux - Convert a file of decimal numbers to the ASCII equivalent?

2024-03-17 04:30:04
How to Linux - Convert a file of decimal numbers to the ASCII equivalent

I can convert a text file to a list of ASCII decimals like this:

$ echo "hello" | od -An -td1 -v -w1
  104
  101
  108
  108
  111
   10

What is the inverse operation? How can I convert the file of decimals back to text? I want to use only common Unix command-line tools. I've been looking at printf but haven't figured out how to make it work.

Solution:

you can use the printf function using the parameter "%c" that treats the input as a single character.

Easy solution: Pipe the output to the inverse function.

echo "hello" | od -An -td1 -v -w1 | awk '{ printf "%c", $1 }'

awk receives the piped information in the first column with ASCII value and sends it as input for the print function.

Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login