2

I have a long text file that looks something like this:

00000000
00001110
00010001
00010000
00001110
00000001
00010001
00001110
...and so on...

I'd like to take this data that is represented in ASCII and write it to a binary file. That is, i do NOT want to convert ASCII to binary, but rather take the actual 1s and 0s and put them in a binary file The purpose of this is so that my EPROM programmer can read the file. I've heard that ob and hexdump are useful in this case but I never really understood how they worked.

If it's to any help I also have the data in hex form:

00 0E 11 10 0E 01 11 0E

How do I do this using a shell script?

1
  • I think you need to use a language like perl or PHP. I can't think of a way to generate binary data in pure bash. Commented Aug 28, 2014 at 23:41

1 Answer 1

1

Something like perl -ne 'print pack "B*", $_' input should get you most of the way there.

Sign up to request clarification or add additional context in comments.

1 Comment

This is perfect! Thanks! cat file.text | tr -d "\n" | perl -ne 'print pack "B*", $_' > file.bin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.