Sponsored Content
Top Forums Shell Programming and Scripting Convert Binary File To Hex In Linux Post 302954373 by wisecracker on Monday 7th of September 2015 09:12:54 AM
Old 09-07-2015
Hi siramitsharma...

I have expanded your zip file and the start bytes are nothing like yours, that helps - not.

So $9, $10, $11, $12 and $13 are BCD AND $15, $16, $17 are HEX values for the year in the file you gave; that is 15\09\03 ; and similarly $18, $19, $20 for the time...

Why did you not tell us that part of the info is BCD and the other part HEX to decimal conversion?

Longhand the second part only for just ONE set of values and added a newline just to make it clear...
The BCD part is easy...
OSX 10.7.5, default bash terminal...
Code:
Last login: Mon Sep  7 13:58:50 on ttys000
AMIGA:barrywalker~> IFS=" "
AMIGA:barrywalker~> ARRAY=( $( cat /tmp/hexstring ) )
AMIGA:barrywalker~> printf "%02d\%02d\%02d %02d:%02d:%02d\n" 0x${ARRAY[14]} 0x${ARRAY[15]} 0x${ARRAY[16]} 0x${ARRAY[17]} 0x${ARRAY[18]} 0x${ARRAY[19]}
15\09\03 18:43:11
AMIGA:barrywalker~> _

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Binary and hex in unix

not much familiar with binary and hex calculation in script programming.... explaination: binary format control the parameter turned on or off in the program stored in hex mode, the question is: how to change 39e to 19e using the binary calculation(although i don't know the command for... (2 Replies)
Discussion started by: trynew
2 Replies

2. UNIX for Advanced & Expert Users

Modifying binary file by editing Hex values ?

Hi , i'm using special binary file (lotus notes) and modifying an hexadecimal address range with windows hex editor and it works fine ! The file is an AIX one and i'm forced to transfert (ftp) it before modifying it and re-transfert ! NOW i would do this directly under AIX ! I can... (4 Replies)
Discussion started by: Nicol
4 Replies

3. UNIX for Dummies Questions & Answers

How to convert binary Unix file to text

Hi all, I have a print control file (dflt) for Oracle which is in binary. As I am going to develope an application in Window environment, I would like to reference the dflt file. But it is in binary format and I cannot access it. Anyone can suggest me how to convert the file into text or... (5 Replies)
Discussion started by: user12345
5 Replies

4. Shell Programming and Scripting

binary/hex output

i want to output something like 2f 00 00 00 but i can't seem to escape characters like i'm used to in some programming languages, so with this: echo "/\0\0\0" >> outputfile i actually get 2f 5c 30 5c 30 5c 30 0a ie the \0 isn't giving me the 00 i need, and in addition it has got an... (8 Replies)
Discussion started by: peterworth
8 Replies

5. UNIX for Dummies Questions & Answers

convert a .tr file to binary in cygwin

I would like to convert a .tr file to a binary file to use for trace purposes. Can anyone provide any insight? (0 Replies)
Discussion started by: sparklezilla3
0 Replies

6. Shell Programming and Scripting

convert hex to binary and send to variable

Folks, can anyone help with a script to convert hex to binary digits, and break the 32 bit binary into packs of 4 and send them to 8 different variables.Any help is sincerely appreciated. Thanks venu Its in korn shell...... (24 Replies)
Discussion started by: venu
24 Replies

7. Shell Programming and Scripting

How to convert a file containing hex code to decimal using script?

The file contains code like the below and need to convert each one into a decimal 00 00 00 04 17 03 06 01 So the output should come as 0 0 0 4 23 3 6 1 (24 Replies)
Discussion started by: necro98
24 Replies

8. 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

9. Shell Programming and Scripting

Convert jpg file to binary format

Hi Team, Here's the requirement. I have a image file in jpg format in unix. Now I need to i. convert the jpg format to binary format ii. followed by loading the binary file to Oracle db. Can anyone help me out? Thanks Krishnakanth Manivannan (4 Replies)
Discussion started by: kmanivan82
4 Replies

10. Shell Programming and Scripting

Want to convert an expect script to binary in Linux

Does anyone know how to convert an expect script to binary in linux?. (3 Replies)
Discussion started by: John Wilson
3 Replies
Math::Polygon::Clip(3pm)				User Contributed Perl Documentation				  Math::Polygon::Clip(3pm)

NAME
Math::Polygon::Clip - frame a polygon in a square INHERITANCE
Math::Polygon::Clip is a Exporter SYNOPSIS
my @poly = ( [1,2], [2,4], [5,7], [1, 2] ); my @box = ( $xmin, $ymin, $xmax, $ymax ); my $boxed = polygon_clip @box, @poly; DESCRIPTION
Cut-off all parts of the polygon which are outside the box FUNCTIONS
polygon_fill_clip1(ARRAY-BOX, LIST-OF-POINTS) Clipping a polygon into rectangles can be done in various ways. With this algorithm (which I designed myself, but may not be new), the parts of the polygon which are outside the BOX are mapped on the borders. The polygon stays in one piece. Returned is one list of points, which is cleaned from double points, spikes and superfluous intermediate points. polygon_fill_clip2(ARRAY-BOX, LIST-OF-POINTS) To be implemented. The polygon falls apart in fragments, which are not connected: paths which are followed in two directions are removed. This is required by some applications, like polygons used in geographical context (country contours and such). polygon_fill_clip3(ARRAY-BOX, OUT-POLY, [IN-POLYS]) To be implemented. A surrounding polygon, with possible inclussions. polygon_line_clip(ARRAY-BOX, LIST-OF-POINTS) Returned is a list of ARRAYS (possibly 0 long) containing line pieces from the input polygon (or line). example: my @points = ( [1,2], [2,3], [2,0], [1,-1], [1,2] ); my @bbox = ( 0, -2, 2, 2 ); my @l = polygon_line_clip @bbox, @points; print scalar @l; # 1, only one piece found my @first = @{$l[0]}; # first is [2,0], [1,-1], [1,2] SEE ALSO
This module is part of Math-Polygon distribution version 1.02, built on September 19, 2011. Website: http://perl.overmeer.net/geo/ LICENSE
Copyrights 2004,2006-2011 by Mark Overmeer. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.12.4 2011-09-19 Math::Polygon::Clip(3pm)
All times are GMT -4. The time now is 03:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy