Improve company productivity with a Business Account.Sign Up

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

turn file into byte array in bash

Greetings,
is there a way to turn a file into a byte array in a bash setting?
Thanks
0
Evan Cutler
Asked:
Evan Cutler
2 Solutions
 
MikeOM_DBACommented:
$ man od
$ od -c MyFile >MyFile.dmp

Open in new window

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

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

Open in new window

0
 
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.
Thanks.
0
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