Solved

turn file into byte array in bash

Posted on 2013-06-06
3
1,421 Views
Last Modified: 2013-06-06
Greetings,
is there a way to turn a file into a byte array in a bash setting?
Thanks
0
Comment
Question by:Evan Cutler
3 Comments
 
LVL 29

Assisted Solution

by:MikeOM_DBA
MikeOM_DBA earned 150 total points
ID: 39226744
$ man od
$ od -c MyFile >MyFile.dmp

Open in new window

:p
0
 
LVL 23

Accepted Solution

by:
nemws1 earned 350 total points
ID: 39227003
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
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 39227038
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now