Sponsored Content
Top Forums UNIX for Advanced & Expert Users Need to convert Binary files to ascii Post 56766 by jim mcnamara on Monday 11th of October 2004 11:22:37 AM
Old 10-11-2004
od will jump to an offset with the -j <offset> qualifier.
The -t u4 will tell od to format the output as an unsigned decimal.

You need to check your od man page because I think the -t qualifier is not always supported, and may only support 16 bit words, not 32 bit words.

Otherwise compile and try this
cc -o bfile bfile.c
bfile `head -c -n 3404 mybinaryfile`

Code:
/* bfile.c */
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
     if (*argv[1])
     {
         if(strlen(argv[1])>3403)
         {
                 char  *p=&argv[1][3401];
                 fprintf(stdout,"%d\n",*(int *)p);
         }
      }
      return 0;
}

You are limited in postion in the file to what _POSIX_ARG_MAX is defined to for your system (in limits.h) - Normally it is 4096.

Last edited by jim mcnamara; 10-11-2004 at 12:27 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

viewing binary files in ASCII

Hi, How to view binary files in ASCII format.???????????????? Bye (2 Replies)
Discussion started by: manjunath
2 Replies

2. UNIX for Advanced & Expert Users

Convert ASCII to BINARY

Here is what I did . . . . I FTP'd several *.pdf files from a web site to a UNIX server, and did not set the transfer mode to BIN, now Adobe thinks that the documents are corrupted. Is there a way to convert the *.pdf files to Binary so that Adobe can open them again. I would just re-download... (2 Replies)
Discussion started by: pc9456
2 Replies

3. UNIX for Advanced & Expert Users

Convert Binary data to ascii data

Friends, I've tried on solaris, but I could n't get ascii data dd if=binaryinputfile bs=1 skip=3800 count=4 | od -t u4 output : INDBU3:/usr/users/FTAMUSER/kk $ dd if=SMP20041006173649188151 bs=1 skip=3800 count=4 | od -t u4 4+0 records in 4+0 records out 0000000 0000000000 0000004... (4 Replies)
Discussion started by: krishna
4 Replies

4. Shell Programming and Scripting

binary to ascii

Hi, Is there a way to convert the binary file to ascii . the binary file is pipe delimited. from source the file(pipe delimited) is ftped to mainframe and from mainframe it is ftped to the unix box using binary format. Is there a way to change it back to ascii and view it? Thanks! (3 Replies)
Discussion started by: dnat
3 Replies

5. UNIX for Dummies Questions & Answers

Ascii or Binary?

Hello all, I am working with ftp servers in unix, and always I have to get and put files but I don't know exactly if I have to get or put them as an ascii or binary. Some files that I use are: .txt, .sav, .fmb, .pct, .sh, .ksh, .dat, .log. Somebody can tell me what is the difference between... (2 Replies)
Discussion started by: Geller
2 Replies

6. Shell Programming and Scripting

convert ascii values into ascii characters

Hi gurus, I have a file in unix with ascii values. I need to convert all the ascii values in the file to ascii characters. File contains nearly 20000 records with ascii values. (10 Replies)
Discussion started by: sandeeppvk
10 Replies

7. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

8. Solaris

Convert files from binary to ASCII

I have a huge files in binary format thanks to help me in finding a way to convert these files from Binary format to ASCII format. (0 Replies)
Discussion started by: PRINCESS_RORO
0 Replies

9. Solaris

ASN Binary to ASCII

Dears, I need help to convert the binary file into ASCII format. Actually we have CDRs which is generated by telecom switch at this is in ASN1 format or binary format, I need to convert those binary formatted file into ASCII format using Perl, or shell scripting. Is there any way to solve... (3 Replies)
Discussion started by: PRINCESS_RORO
3 Replies

10. Shell Programming and Scripting

Convert Hex to Ascii in a Ascii file

Hi All, I have an ascii file in which few columns are having hex values which i need to convert into ascii. Kindly suggest me what command can be used in unix shell scripting? Thanks in Advance (2 Replies)
Discussion started by: HemaV
2 Replies
Binary.createBlock(3kaya)				       Kaya module reference					 Binary.createBlock(3kaya)

NAME
Binary::createBlock - Create a new, uninitialised block for binary data. SYNOPSIS
Binary createBlock( Int bsize ) ARGUMENTS
bsize The size of the block. Block sizes cannot be changed once the block is created. DESCRIPTION
Create a new, uninitialised block for binary data. Remember to use Builtins.byteLength(3kaya) instead of Builtins.length(3kaya) if you want to store Strings in these, as you may have problems with multi-byte characters otherwise. The uninitialised contents of this block are not guaranteed to be zeroes. AUTHORS
Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/ LICENSE
The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation. RELATED
Binary.Binary(3kaya) Kaya October 2012 Binary.createBlock(3kaya)
All times are GMT -4. The time now is 01:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy