Re: writing binary data
From: Jean-Marc Monnez (monnez.jean-marc_at_AGORA.MSA.FR)
Date: 03/29/04
- Previous message: Bob.Kelley_at_BRINKSINC.COM: "Re: Async I/O at AIX 5.2"
- In reply to: Holger.VanKoll_at_SWISSCOM.COM: "writing binary data"
- Next in thread: Bill Thompson: "Re: writing binary data"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Mar 2004 11:52:43 +0200 To: aix-l@Princeton.EDU
The escape you need in echo or print is \0 followed by the octal value
of the byte.
F.e. to add 80 (hex), use 200 (octal).
echo "\0200\c" > binfile
Your main work is octal conversion for each byte....
Regards
-- JMM
-----------------------------
Jean-Marc MONNEZ
MSA / AGORA / ATD
monnez.jean-marc@agora.msa.fr
-----------------------------
Holger.VanKoll@SWISSCOM.COM a écrit :
> Hello Aix-lers,
>
> I have this string
>
> 80DF000038600002540807FE38A00000
>
> containing 16 bytes ( 80 , DF , 00, 00 and so on).
>
> I want to have a binary file containg those bytes.
> So that
> cat file|od -x
> would give this output:
>
> 0000000 80DF 0000 3860 0002 5408 07FE 38A0 0000
>
> I could use cut to get every single byte; f.e.
>
> echo 80DF000038600002540807FE38A00000|cut -c1-2
> echo 80DF000038600002540807FE38A00000|cut -c3-4
>
> and I also know how to convert those bytes to decimal, if necessary.
>
> I just see no way to write binary data.
> If $a contains 80 (hex) or 128 (decimal), a echo $a >filename just
> creates a textfile with 128.
>
> Any suggestions?
>
> Regards,
>
> Holger
- Previous message: Bob.Kelley_at_BRINKSINC.COM: "Re: Async I/O at AIX 5.2"
- In reply to: Holger.VanKoll_at_SWISSCOM.COM: "writing binary data"
- Next in thread: Bill Thompson: "Re: writing binary data"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|