Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2194
  • Last Modified:

turn file into byte array in bash

is there a way to turn a file into a byte array in a bash setting?
Evan Cutler
Evan Cutler
2 Solutions
$ man od
$ od -c MyFile >MyFile.dmp

Open in new window

nemws1Database AdministratorCommented:
What do you mean by byte array?  A file is already an array of bytes. ;-)

Something like this (hex):
bytearray=(`od -x $filename | cut -c9- `)
echo "bytes:" ${bytearray[@]}

Open in new window

Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
thanks. perfect.
I'm sending a zip file into a webservice using a curl from a bash script.

Just to add to the fun, it's not a file-upload.  it's a bytearray package in the soap message.  Fun.

That worked.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now