Sponsored Content
Full Discussion: How to parse a binary file?
Top Forums UNIX for Advanced & Expert Users How to parse a binary file? Post 302810549 by wisecracker on Wednesday 22nd of May 2013 03:16:13 AM
Old 05-22-2013
I really have no idea how to parse NIBBLES directly but this as a byte transfer should be a starter and splitting into two halve should be very easy...

Search the forums for more info on adding leading zeros, lower to upper case, etc...
It's all on here...

Research the bc command for more info:-
Code:
#!/bin/bash
# NOTE! Uppercase required...
for bits in 00 FF 55 AA
do
        BITS=`echo "obase=2; ibase=16; $bits" | bc`
        printf "$BITS\n"
done

Test using this Macbook Pro...
Code:
Last login: Wed May 22 07:12:22 on ttys000
Barrys-MacBook-Pro:~ barrywalker$ ./hextobit.sh
0
11111111
1010101
10101010
Barrys-MacBook-Pro:~ barrywalker$


Last edited by wisecracker; 05-22-2013 at 04:23 AM..
 

10 More Discussions You Might Find Interesting

1. Solaris

compiled binary file gives "cannot execute binary file"

Hi, I have two Solaris machines. 1. SunOS X 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Blade-1500 2. SunOS Y 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-60 I am trying to buiild a project on both these machines. The Binary output file compiled on machine 2 runs on both the machines. Where... (0 Replies)
Discussion started by: scgupta
0 Replies

2. Shell Programming and Scripting

dd - binary file

I have a task that says: make a file (called binaryfile ) that contains 4 bytes of NULL data 6 bytes of random data 8 bytes of 1 10 bytes of 5 and 12 bytes of 9. For the first 2, I can used : dd if=/dev/null of=binaryfile bs=8 count =4 and dd if=/dev/urandom of=binaryfile bs=8... (3 Replies)
Discussion started by: spiriad
3 Replies

3. UNIX for Dummies Questions & Answers

Binary file

How can we see the contents of a binary file? (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

4. Shell Programming and Scripting

To log binary file output to a txt file

Hi, I wrote a small script whose function is to execute the postemsg provided if the threshold breaches. I want to log this postemsg messages to a log file. But I am not able to do. Can someone throw some light on how to log the output of this. I am pasting a snippet of that code. ... (2 Replies)
Discussion started by: dbashyam
2 Replies

5. UNIX for Dummies Questions & Answers

Pipe binary file matches grep results to file

I am using grep to match a pattern, but the output is strange. $ grep -r -o "pattern" * Gives me: Binary file foo1 matches Binary file foo2 matches Binary file foo3 matches To find the lines before/after, I then have to use the following on each file: $ strings foo1 | grep -A1 -B1... (0 Replies)
Discussion started by: chipperuga
0 Replies

6. UNIX for Advanced & Expert Users

How to copy a binary file while the file is being written to by another process

Hello, Can I copy a binary file while the file is being written to by another process? Another process (program) “P1” creates and opens (for writing) binary file “ABC” on local disk. Process P1 continuously write into ABC file every couple of seconds, adding 512-byte blocks of data. ABC file... (1 Reply)
Discussion started by: mbuki
1 Replies

7. Shell Programming and Scripting

Output redirection of c binary file to a file in shell script is failing

I am struck up with a problem and that is with output redirection. I used all the ways for the redirection of the output of c binary to a file, still it is failing. Here are the different ways which I have used: ./a.out | tee -a /root/tmp.txt 2>&1 ./a.out | tee -a /root/tmp.txt 1>&1 ./a.out |... (2 Replies)
Discussion started by: Maya29988
2 Replies

8. UNIX for Dummies Questions & Answers

[AIX] Binary file warning for text file.

Hello guys, We had to move from a DC to another, and we are now facing an "issue" with some text files. Looks like that some of our log files are set as binary: file TuxConnectorURA.20121012 TuxConnectorURA.20121012: data or International Language text less TuxConnectorURA.20121012... (2 Replies)
Discussion started by: EnioMarques
2 Replies

9. Shell Programming and Scripting

Python Binary File Read and Parse

Hi to everyone :), i have a challenge right now in python that for now needs a bit of help in one part of the c0de. The task is create a new file with the name of the file defined by the ASCII content between the 3 byte and the 16 byte that is parsed from the binary file, the file is over 20 Mb i... (0 Replies)
Discussion started by: drd0spt
0 Replies

10. 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
Binary.setBlockData(3kaya)				       Kaya module reference					Binary.setBlockData(3kaya)

NAME
Binary::setBlockData - Set the contents of a block. SYNOPSIS
Void setBlockData( var Binary block, Int offset, [Int] bdata ) ARGUMENTS
block The binary block offset The offset to start at (zero-indexed) bdata The data to write, as an array of Int s DESCRIPTION
Set the contents of (part of) a block from an array. An Binary.OffsetOutOfRange(3kaya) Exception will be thrown if this would cause a write outside the bounds of the block. The following bits of code are equivalent: setBlockData(block,offset,bdata); // is equivalent to for byte@idx in bdata { poke(block,offset+idx,byte); } However, setBlockData is more efficient and checks bounds before any data is written - the above for loop could write partial data if off- set+idx was greater than blockSize(block) 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) Binary.array(3kaya) Binary.copyBlock(3kaya) Binary.getBlockChunk(3kaya) Binary.poke(3kaya) Binary.pokeString(3kaya) Kaya October 2012 Binary.setBlockData(3kaya)
All times are GMT -4. The time now is 09:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy